Information Technology Reference
In-Depth Information
$ git checkout master
Now the history printed with $ git l contains all of the revisions shown in List-
ing 3-6 .
You can use $ git checkout again to switch to some other revision, for ex-
ample:
$ git checkout 564f
To return to normal state use:
$ git checkout master
How It Works
The second method of restoring a previously saved snapshot is to use the following
command:
$ git checkout [REVISION]
This command works differently than $ git reset discussed in Recipe 3-5.
The $ git checkout command performs the three following operations:
• It enters a detached HEAD state.
• It resets the state of the working directory to the specified revision.
• It removes from the history all the revisions that were created after a spe-
cified revision.
The detached HEAD is a special state of the repository in which you are not on any
branch. We will discuss branches in greater detail in chapter 5 , 6, 7, and 10. Right now,
to use $ git checkout , you only need to know:
• That the $ git checkout [SHA-1] command enters a detached
HEAD state.
• How to check the state of your repository.
• How to return from the detached HEAD to the normal state.
Search WWH ::




Custom Search