Recovering a rebased commit from GitHub
22 February 2016
Tweet Follow @hazula
Tweet Follow @hazula
A stupid way to recover a commit that has been rebased and is now unreachable (ref):
- Given unreachable commit
https://github.com/org/repo/commits/332a2b9f43f1f8d7730e0a01356ea183dfadd470
- See if you can compare it to any earlier commit you have, e.g.
https://github.com/org/repo/compare/f571415f4da9cc28edc83242e353966677dabcd2...332a2b9f43f1f8d7730e0a01356ea183dfadd470
. - Push your local commit up to a recovery branch:
git checkout f571415f4da9cc28edc83242e353966677dabcd2; git checkout -b recovery; git push origin recovery
. - See the patch commits:
https://github.com/org/repo/compare/recovery...332a2b9f43f1f8d7730e0a01356ea183dfadd470.patch
and download as recovery.patch (you could curl unless it’s private so blah blah) - Apply the patch commits and push up:
git am recovery.patch && git push origin recovery
.
Tada! You have now recovered and shared that commit!
blog comments powered by Disqus