0

I was using a detached branch without know it, then i used git commit -m <commit_name>.

Here the problem: I returned to a previous branch and when I wanted to return to what I had done, i couldn't find the branch or commit

1 Answers1

1

git reflog at rescue. Unreachable commits - those not reachable via any branch or tag - can still be checkouted, as they are still in the local repository (at least during sometime, if git gc is not invoked).

You can locate the hash of your lost commit, the one committed in detached mode, inspecting the reflog:

git reflog

Once you locate it, do:

git checkout <hash_of_lost_commit>

And then create a new branch normally:

git checkout -b my_new_branch
msune
  • 231
  • 1
  • 3