Recover from inadvertent skip during rebase

I just tried to rebase a very old branch with a minor modification onto my master.
There was a problem with merging just one of the three files involved, so I did an unthinking –skip, thinking that it would just skip that file, but as it happened, it seems to have skipped all my changes, and rolled forwards. So now the rebase is finished, and my changes seem to have disappeared.

I’ve seen the question about undoing rebase, but it’s all greek to me, I see the reflog, but I don’t know which commit the branch was attached to before the rebase.

  • Is it possible to let Gerrit randomly pick a reviewer?
  • Enforce core.autocrlf=input through .gitattributes
  • See treeview for branches in Atlassian Stash
  • Why is git flow feature checkout being deprecated? What should I be using instead?
  • Git - .gitignore Ignores folders throughout repo
  • create branch with N-last commits
  • In any case, I don’t really need to undo the rebase, I just want to be able to recover the changes in the two files. Is there anyway to do this properly (failing this, I’ll just have to restore yesterday’s backup of my repository and pick the bits out by hand).

  • Modify history of a git topic branch that used merges to use rebases
  • Jenkins keeps adding job in the build queue and keeps building them
  • Add date to git commit message automatically
  • Is there an equivalent to git stash in perforce?
  • GIT push whines about untrusted X11 forwarding setup failed
  • How to use Vim to quickly see Mercurial or Git changes
  • One Solution collect form web for “Recover from inadvertent skip during rebase”

    First, make a tarball of your git working folder. This makes it easier to try it several times.

    Lets assume the following happened

    • git checkout another-old-branch
    • git rebase master
    • some problems (which you skipped)

    at this point you are now still in another-old-branch and your reflog shows you:

    6f8348f HEAD@{0}: rebase: <commit message of last commit in another-old-branch>
    e547ec0 HEAD@{1}: checkout: moving from another-old-branch to e547ec0d2a558d189464fc57192066b34ec5f28f^0
    65cedf8 HEAD@{2}: checkout: moving from master to another-old-branch
    

    Imagine that branchs are like symlinks (or pointers), all we have to do is let the branch ‘another-old-branch’ point back on the old commit-id. the old commit is is still there, and it wasn’t touched by your rebase. kinda: ‘hey git, another-old-branch is e547ec0d2, forget everything else that happened’

    In our case here that was e547ec0d2a558d189464fc57192066b34ec5f28f, so what we have to do now is

    • git checkout another-old-branch # if you aren’t already there
    • git reset –hard e547ec0d2a558d189464fc57192066b34ec5f28f

    now your branch is back to normal. And you can retry your rebase.

    Please note that your reflog is by now a little bit more complicated than aboves example. but it should stil lbe there somewhere…

    good luck!

    Git Baby is a git and github fan, let's start git clone.