Information Technology Reference
In-Depth Information
$ cd git-recipes
$ git clone-with-branches 05-01 05-04
$ cd 05-04
The repository now looks like Figure 5-1 . As you can see in Figure 5-8 , the parent
of revision x1 is i1 . As you probably remember from Recipe 3-6 the command $
git checkout [REVISION] , when used with SHA-1 name, enters the detached
HEAD state and resets the working directory. To use it we need a name for the i1 revi-
sion. We could check the name using the following $ git log command:
$ git log --oneline --grep=i1 info
The first parameter, --oneline , sets the output's format. The second parameter, -
-grep=i1 , acts as a filter. Only the revisions with the comment containing the i1
string are included. The third parameter, info , sets the starting point for the search.
Therefore, only the commits available in the branch info will be analyzed. The output
of the above command will include only one commit, for example,
6f4364e i1
There is also a much easier way to refer to i1 than using the abbreviated SHA-1
name. The i1 revision can be addressed as a second parent of the revision pointed to
by the info branch. It is formally written as info 2 . Thus the command:
$ git checkout info 2
enters the detached HEAD state and resets the working directory to the commit i1 .
The command prints clear information about entering the detached HEAD state. Right
after the command the .git/HEAD points to i1 commit. This state is depicted in Fig-
ure 5-9 .
 
Search WWH ::




Custom Search