I sometimes check out some previous version of the code to examine or test. I have seen instructions on what to do if I wish to modify previous commits — but suppose I make no changes. After I’ve done e.g. git checkout HEAD^, how do I get back to the tip of the branch?.. git log no longer shows me the SHA of the latest commit.
I sometimes check out some previous version of the code to examine or test.
Share
If you know the commit you want to return to is the head of some branch, or is tagged, then you can just
You can also use
git reflogto see what other commits your HEAD (or any other ref) has pointed to in the past.Edited to add:
In newer versions of Git, if you only ran
git checkoutor something else to move yourHEADonce, you can also doto switch back to wherever it was before the last checkout. This was motivated by the analogy to the shell idiom
cd -to go back to whatever working directory one was previously in.