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!
Yes, you can use git checkout <sha1>
.
As stated in the comments, you can use:
It depends on what you mean by "update my local repository". If you want to remain on your current branch, you can reset your branch to a prior commit with:
git reset --hard <SHA1>
This will put the state of your branch to that of SHA1. The command git checkout changes the branch you are working on, so it will also change the state of the local repository, but the branch will no longer be the same.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With