Information Technology Reference
In-Depth Information
How It Works
The process of storing a new file in a repository always consists of two steps. There
isn't another way to do it. When you create a new file, at first it is
untracked
, which
means that git doesn't store the file in the repository and doesn't track the contents of
the file. The state of the file returned by
$ git status -s
command is denoted by
two question marks:
?? new.txt
If you want to store the file in a revision, you first add the file to the staging area. This
is done with:
$ git add new.txt
The
staging area
is a list of modifications that will be included in the very next re-
vision made with the
$ git commit
command. The staging area is stored in the
.git/index
file. The files added to the staging area are called
staged files
. After
$
git add new.txt
the shortened status command
$ git status -s
prints:
A_ new.txt
As you can see, new files added to the staging area are denoted by
A_
.
Hint
You can use wildcard characters
*
and
?
for a
$ git add
command.
When the file is in the staging area you can create a new revision with:
$ git commit -m "Some explanation…"
All the changes that were included in the staging area go into the revision. The file
is stored in a repository and can be now described as
unmodified
. As you probably no-
ticed the commands:
$ git status
$ git status -s
did not print any information about unmodified files.