Managing worktrees and the staging area
In Chapter 3, Developing with Git, we learned that, besides the working directory where you work on changes, and the local repository where you store those changes as revisions, there is also a third section between them: the staging area, sometimes called the index.
In the same chapter, we also learned how to examine the status of the working directory, and how to view the differences. We saw how to create a new commit out of the working directory, or out of the staging area.
Now it is time to learn how to examine and modify the state of individual files.
Examining files and directories
It is easy to examine the contents of the working directory: just use the standard tools for viewing files (for example, an editor or a pager) and examining directories (for example, a file manager or the dir
command). But how do we view the staged contents of a file, or the last committed version?
One possible solution is to use the git show
command with the appropriate...