I have a git repository.
When I do ‘git branch’, it said
$ git branch
* com-2.1-SS
and then I do ‘git log’, i get a list of my commit
$ git log
commit ff878926b78614e8bf6af161da06070618e9ff6b
commit 3ffda8cec60a74a718fb25fb7a9fe4b3c4381137
commit bf6bb3427d8031d8e172c3b8b7909c8580e929cd
So I want to check out my repository to 3ffda8cec. So I did ‘git checkout 3ffda8cec’.
So far so good. It works and I get want I want.
But my question is how can I get back to com-2.1-SS?
i.e. reverse the fact that I ‘git checkout 3ffda8cec’
When I do ‘git branch’, it said
$ git branch
* (no branch)
When I do ‘git checkout git checkout com-2.1-SS
error: pathspec 'com-2.1-SS' did not match any file(s) known to git.
git reflog will show you the different values a branch tip had and you can checkout it to go back to a previous state.
Your case is easier since you still know now that the sha1 of
com-2.1-SSbefore thegit checkoutwasff878926b78614e8bf6af161da06070618e9ff6b(which is basically whatgit reflogdo) so you can directly do:Althoug I don’t understand from your description at which point your branch was deleted, you can recreate your branch after the checkout with: