I did a checkout to an earlier commit:
git checkout 12345
Then back to the last commit:
git checkout 56789
And then continued committing and I’m:
Not currently on any branch.
Perhaps, I should’ve done:
git checkout master
After the first checkout, instead of pointing to a commit id.
Still, any idea how to get my latest commits into the master branch (which is a few commits behind)?
Thanks
When you do
git checkout 12345you will be in no branch state. Do not do that. This is meant for commit inspection rather than working in it.If you are on master and want to reset your master to the commit that you wanted, use
git reset 12345( or supply--hard) If you wanted to branch, usegit checkout -b <name> <sha1>to create a branch at that point and start working there.Similarly while coming back, like you mentioned, you should have done
git checkout masterNow that you have committed over 56789, note down the commit over 56789, and then checkout master, and do: