I'm trying to rebase the work of a colleague.
First, I get a ton of conflicts where <<<<< head seams to contain the new code.
Then after a while I get the following error:
fatal: update_ref failed for ref 'refs/heads/dev_504': cannot lock ref 'refs/heads/dev_504': ref refs/heads/dev_504 is at XXXXXXX but expected XXXXXXXX Could not move back to refs/heads/dev_504
Then if I try to continue anyway I get the following error:
fatal: cannot resume: .git/rebase-apply/final-commit does not exist.
How can I fix this so the rebase won't give an error?
In particular, failure to apply a patch during a git rebase is a common problem that can be very destabilizing for the inexperienced user.
The golden rule of git rebase is to never use it on public branches. The rebase moves all of the commits in main onto the tip of feature . The problem is that this only happened in your repository. All of the other developers are still working with the original main .
You can run git rebase --abort
to completely undo the rebase. Git will return you to your branch's state as it was before git rebase was called.
You can run git rebase --skip
to completely skip the commit. That means that none of the changes introduced by the problematic commit will be included. It is very rare that you would choose this option.
You can fix the conflict.
Failing that, you should re-create your branch or you can be able to remove the .git/rebase-merge directory, which contains the rebase state.
Apparently the branch onto which you want to rebase, was also rebased between the time you branched off, maybe cleaning history up or rebasing on yet another branch. If so, you need to:
git rebase --abort
git fetch
now the interesting part:
git rebase --onto BUDDY_BRANCH YOUR_BRANCH~ YOUR_BRANCH
e.g. you branched of your local master (checkout of origin/master), a new branch test_branch (which you now want to update with current origin/master)
git rebase --onto master test_branch~ test_branch
What this does is in simple terms, it takes your branches initial parent commit, finds it's counterpart in current master and rebases based on that.
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