Information Technology Reference
In-Depth Information
$ git add -A
After this command the file is in the
M_
state. The command
$ git status -
sb
would print:
M_ number.txt
Now, the command
$ git diff
prints empty results. This means that the file in
the staging area is identical to the file in the working directory. If you want to compare
the file in the staging area to the file stored in
HEAD
, you can use the additional para-
meter
--staged
:
$ git diff --staged
The above command compares the file stored in
HEAD
and the file in the staging
area. The result will be exactly the same as in
Listing 13-3
.
Hint
The command
$ git diff
compares the working directory to the staging
area. The command
$ git diff --staged
compares the staging area to the ver-
sion stored in the revision pointed by HEAD.
Now commit the staged changes with:
$ git commit -m "Numbers: foo bar"
The command
$ git status -sb
proves that your repository is clean. All
three snapshots, HEAD, the staging area, and the working directory, contain exactly the
same version of file
numbers.txt
. Thus both commands:
$ git diff
$ git diff --staged
print empty results.
Finish the recipe by comparing the next to the last revision,
HEAD
∼
, and the last re-
vision,
HEAD
, with the following command:
$ git diff --unified=1 HEAD
∼
HEAD