12

This is a variant on similar questions, where commits end up in a headless branch. I am adding this question to cover this particular case. In my case, the issue is the following:

  • I did a git submodule update, which left the repository in a headless state (and I forgot to checkout again to master)
  • I committed code, several commits in fact
  • As I was about to push to github, I realized I was in a headless state, and switched to the master branch (the github app makes it soooo easy)

The result: my commits were now in git limbo.

1 Answer 1

28

Based on answers here and there, I found my way out using git reflog:

> git reflog
6b0da0d HEAD@{0}: rebase finished: returning to refs/heads/master
6b0da0d HEAD@{1}: pull --rebase --progress --prune --recurse-submodules=on-demand origin: check
d55ecfb HEAD@{2}: checkout: moving from fed7916169d740644dbbd9ea48e2d2cd510ce32d to master
fed7916 HEAD@{3}: commit: more secret stuff.
818bf20 HEAD@{4}: commit: incredible stuff I am doing, hopefully won't end up in limbo.
...etc...

The commit fed7916 is the one I want to merge to master. For this, I simply typed:

> git merge fed7916

The merge went without problem (it should since it was anyway branched from where master was at) and all my commits were now reachable again, and ready to be pushed to github.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.