Sometimes you would find that you’re not on any branch when
git branch, is described here. This usually happens when you’re using a submodule inside another project. Sometimes you’ll make some changes to this submodule, commit them and then try to push them up to a remote repository, for more details see here:
git branch * (no branch) master
But,, when checkout master, you’ll lost the specific branch named
git branch * master
So, how can we got it back again?
As long as you’ve not done a
git gc, then you’ve not lost anything. All you need to do is find it again What do you get with:
git reflog # (the commit-ish will be on the first line)
That should show you what happened, and the id of the missing node(s).
To get back to it, just do a
git checkout <commit-ish> and your old pseudo branch is restored. also your can merge the specific
<commit-ish> to your master.
git checkout master git merge <commit-ish>