Go to particular revision
Before executing this command keep in mind that it will leave you in detached head status
Use git checkout <sha1>
to check out a particular commit.
Where <sha1>
is the commit unique number that you can obtain with git log
Here are some options after you are in detached head status:
- Copy the files or make the changes that you need to a folder outside your git folder, checkout the branch were you need them
git checkout <existingBranch>
and replace files - Create a new local branch
git checkout -b <new_branch_name> <sha1>
To go to a particular version/commit run following commands. HASH-CODE you can get from git log --oneline -n 10
git reset --hard HASH-CODE
Note - After reset to particular version/commit you can run git pull --rebase
, if you want to bring back all the commits which are discarded.
You can get a graphical view of the project history with tools like gitk
. Just run:
gitk --all
If you want to checkout a specific branch:
git checkout <branch name>
For a specific commit, use the SHA1 hash instead of the branch name. (See Treeishes in the Git Community Book, which is a good read, to see other options for navigating your tree.)
git log
has a whole set of options to display detailed or summary history too.
I don't know of an easy way to move forward in a commit history. Projects with a linear history are probably not all that common. The idea of a "revision" like you'd have with SVN or CVS doesn't map all that well in Git.