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:
master
branch (the github app makes it soooo easy)The result: my commits were now in git limbo.
The process for recovering a deleted commit is quite simple. All that is necessary is to use `git reflog` to find the SHA value of the commit that you want to go to, and then execute the `git reset --hard <sha value>` command.
It is stored in Git's object database directly. The tree object for the directory where the submodule lives will have an entry for the submodule's commit (this is the so-called "gitlink").
Pulling with submodules. Once you have set up the submodules you can update the repository with fetch/pull like you would normally do. To pull everything including the submodules, use the --recurse-submodules and the --remote parameter in the git pull command .
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With