how to update to a specific commit in git?

Viewed 13688

I am new to git and I would like to know if I can update my local repository to a specific commit. Is this possible using checkout?

git checkout <commitId>

exp

git checkout 55215860452c5c6fb11eac6f51d63abb187e7

Thanks in advance!

4 Answers

Here is the way with full steps to go to a specific commit in Git.

1. git clone https://github.com/thoughtbot/bitters
2. cd bitters
3. git checkout 95cd30a  

#  You can find your commit number in git logs or in website.

4. git log

git commit --amend -m "New commit message." But only for the previous commit and the commit has not been pushed to a remote repository.

Related