How to checkout a specific version of git repository
To view the commit history of the current project:
1 |
$ git log |
Sample output :
1 2 3 |
commit fb0d90ec75601304348168bb988ebdbf10c260 Author: Author name<email@somedomain.com> Date: Thu Oct 13 17:30:46 2016 +0300 |
You will get the output like above, There is one unique identifier here that is hash, In above case it is
fb0d90ec75601304348168bb988ebdbf10c260
So you can use this hash to go back to that version in any public repository. if you want to go to a specific git version use following command.
Check out specific git revision or version :
1 2 |
$ git checkout <checksum_hash> $ git checkout fb0d90ec75601304eed98168bb988ebdbf10c260 |
Sample output :
1 2 3 4 5 6 7 8 9 10 11 12 |
Note: checking out 'fb0d90ec75601304eed98168bb988ebdbf10c260'. You are in 'detached HEAD' state. You can look around, make experimental changes and commit them, and you can discard any commits you make in this state without impacting any branches by performing another checkout. If you want to create a new branch to retain commits you create, you may do so (now or later) by using -b with the checkout command again. Example: git checkout -b new_branch_name HEAD is now at fb0d90e... Fix CANCELLing of transactions not forwarded. |
now git status will give you are using detached version. Something like below.
1 |
$ git status |
Output:
1 |
HEAD detached at fb0d90e |