Go to particular revision-Git checkout specific commit

484    Asked by CarolBower in Devops , Asked on Apr 9, 2021

I cloned a git repository of a certain project. Can I turn the files to the initial state and when I review the files go to revision 2, 3, 4 ... most recent? I'd like to have an overview of how the project was evolving.

Answered by Carol Bower

To go into a particular version you can use this command to solve git checkout specific commit error

  git checkout 

This will go to the particular version and you need to use the full sha1

Note: If you need to find out the sha1 of the next commit You should run git log --oneline and stick the output into a text file for reference. Another option, if your history is linear, and is easy to figure out how many commits there are from the first commit till master and use

git checkout master~x 
(if there are x number of commits), then
git checkout master~(x-1)

Thus you can go to a particular version to get it done right.

Hope my answer helps you!



Your Answer

Interviews

Parent Categories