I have a local git repository with only the main branch. So I did a few commits. Afterward, I decided to go back to the first commit. So I did
git checkout xxxxxx
But now when I do git log
I can only see the first commit. How do I get back to the latest code?
git checkout master
?git checkout
does not delete anything unstaged or overrides uncommitted changes. This is whatgit reset
does. And yes, you have to be careful when doing agit reset --hard
. But this is not the case forgit checkout
.checkout
is safe!