Information Technology Reference
In-Depth Information
Problem
The operation of restoring a working directory to a given revision can be performed
with a
$ git reset
or a
$ git checkout
command. In Recipe 3-5 you re-
stored old snapshots with a
$ git reset
command. Now, you want to achieve sim-
ilar results with a
$ git checkout
command.
Solution
Clone the repository from Recipe 3-4:
$ cd git-recipes
$ git clone 03-04 03-06
$ cd 03-06
the output of
$ git l
for future reference.
Now, restore the working directory to the very first revision, named
7cfb
:
$ git checkout 7cfb
This command changes the repository's state into a
detached HEAD
. You can veri-
fy this with:
$ git status -sb
The output should be:
## HEAD (no branch)
The working directory now contains one file
sing-a-song-of-six-
pence.txt
and the history printed with
$ git l
consists of one revision only:
7cfb Sing a song of sixpence
Return it to the normal state with: