31.1. Checkout based on commits and working tree
git checkout, based on commit ID
You can check out arbitrary revisions of your file system via the git checkout command followed by the commit ID. This command will reset your complete working tree to the status described by this commit.
The commit ID is shown if you enter the
git log
command.
The following command shows the log.
# displays the commit history of the repository
# which contains the commit ID, author, message etc.
git log
The following listing shows an example output of a Git log command.
commit 046474a52e0ba1f1435ad285eae0d8ef19d529bf
Author: Lars Vogel <Lars.Vogel@gmail.com>
Date: Wed Jun 5 12:13:04 2013 +0200
Bug 409373 - Updates version number of e4 tools
Repairs the build
commit 2645d7eef0e24195fc407137200fe7e1795ecf49
Author: Lars Vogel <Lars.Vogel@gmail.com>
Date: Wed Jun 5 12:00:53 2013 +0200
Bug 409373 - Updates version number of e4 CSS spy features
31.2. Example: Checkout a commit
To checkout a specific commit you can use the following command.
# checkout the older revision via
git checkout [commit_id]
# based on the example output this could be
git checkout 046474a52e0ba1f1435ad285eae0d8ef19d529bf
# or you can use the abbreviated version
git checkout 046474a5
If you checkout a commit, you are in the detached head mode and commits in this mode are harder to find after you checkout another branch. Before committing it is good practice to create a new branch. See Detached HEAD for details.
|
0 comments:
Post a Comment