Skip to content

Instantly share code, notes, and snippets.

@bf4
Created January 28, 2016 19:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bf4/5a6577891aaeaba5718b to your computer and use it in GitHub Desktop.
Save bf4/5a6577891aaeaba5718b to your computer and use it in GitHub Desktop.
Recovering a rebased commit I can still see in the GitHub web interface

A stupid way to recover a commit that has been rebased and is now unreachable (ref):

  1. Given unreachable commit https://github.com/org/repo/commits/332a2b9f43f1f8d7730e0a01356ea183dfadd470
  2. See if you can compare them to any earlier commit you have https://github.com/org/repo/compare/f571415f4da9cc28edc83242e353966677dabcd2...332a2b9f43f1f8d7730e0a01356ea183dfadd470
  3. Push your local commit up to a recovery branch git checkout f571415f4da9cc28edc83242e353966677dabcd2; git checkout -b recovery; git push origin recovery
  4. 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)
  5. Apply the patch commits and push up. git am recovery.patch && git push origin recovery
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment