News for hackers. Stuff that matters.
Re:Honey I Squashed the Commits by lloeki on Wednesday August 22, 2012 @07:12AM (#4416779)
You don't even have to cherry-pick. Use git reflog to find the topmost correct sha1 (or in the example, right after the rebase, HEAD@{4}), and then do

    git checkout -b revovery
    git reset --hard HEAD@{5} #(the checkout made HEAD change, hence +1)
or even faster:

    git branch recovery -f HEAD@{4}
The key here is to understand that git commit objects include a reference to their parents, and that git merely constructs a branch's history by evaluating the ref to a sha1 and walking over objects recursively. So to recover we merely make something point at the topmost sha1.

Then, in the case of additional commits that came after the squash, you use git rebase --onto to replay the commits that came after the squash on top of the unsquashed commits, which would give us:

   git checkout -b recovery
   git rebase --onto last_sha1_before_squash squashed_commit_sha1 recovery
The checkout -b is just so that rebase will handily move that pointer for us (see man git-rebase) while rebase will replay commits from squashed_commit_sha1's child up to the commit currently pointed at by recovery, over last_sha1_before_squash (again, see man page)
Re:Honey I Squashed the Commits by latchkey on Wednesday August 22, 2012 @01:23PM (#4418434)
Nice! Thanks for the explanation.