Information Technology Reference
In-Depth Information
$ git show --name-only HEAD
$ git show --name-only HEAD
$ git show --name-only HEAD 2
How It Works
To get a deeper insight into the way the $ git reset command transforms your re-
pository you need a thorough understanding of the structure of the repo. The repository
consists of:
• The working directory
• The staging area
• The database
The HEAD stored in .git/HEAD points to one of the commits stored in the data-
base.
The working directory can be interpreted as a single snapshot of your project. That's
clear. But in the same way you can also treat the staging area and your HEAD pointer
as two different snapshots. Thus we can say that in any given point of time your repos-
itory operates on three different snapshots:
• The first snapshot—the working directory
• The second snapshot—the staging area
• The third snapshot—the snapshot stored in the revision pointed by HEAD
Let's suppose that you have just created a revision with $ git simple-commit
lorem . The repository is clean and the working directory contains a file named lor-
em.txt storing a string lorem .
When the repository is clean all three snapshots—the working directory, the staging
area, and HEAD—are identical. Let's modify the lorem.txt file with $ echo
foo > lorem.txt . After this operation the command $ git status -sb
prints:
_M lorem.txt
The lorem.txt file stored in the three snapshots contains:
Search WWH ::




Custom Search