I've just tried to rebase some changes I'm submitting to a remote repository, and can't get it to complete after I resolve conflicts. I tried to rebase as follows:
$ git rebase upstream/master
First, rewinding head to replay your work on top of it...
Applying: My Commit Message
Using index info to reconstruct a base tree...
M dir_a/dir_b/dir_c/myfile.py
.git/rebase-apply/patch:51: trailing whitespace.
.git/rebase-apply/patch:56: trailing whitespace.
.git/rebase-apply/patch:128: trailing whitespace.
.git/rebase-apply/patch:141: trailing whitespace.
.git/rebase-apply/patch:145: trailing whitespace.
warning: squelched 3 whitespace errors
warning: 8 lines add whitespace errors.
Falling back to patching base and 3-way merge...
Auto-merging dir_a/dir_b/dir_c/myfile.py
CONFLICT (content): Merge conflict in dir_a/dir_b/dir_c/myfile.py
error: Failed to merge in the changes.
Patch failed at 0001 My Commit Message
The copy of the patch that failed is found in: .git/rebase-apply/patch
When you have resolved this problem, run "git rebase --continue".
If you prefer to skip this patch, run "git rebase --skip" instead.
To check out the original branch and stop rebasing, run "git rebase --abort".
after resolving the conflict, I staged and committed my changes:
$ git add dir_a/dir_b/dir_c/myfile.py
$ git commit dir_a/dir_b/dir_c/myfile.py -m"Fixed rebase conflicts"
[detached HEAD a5a4f3b3e] Fixed rebase conflicts
1 file changed, 193 insertions(+), 13 deletions(-)
But when I try to continue, it fails
$ git rebase --continue
Applying: My Commit Message
No changes - did you forget to use 'git add'?
If there is nothing left to stage, chances are that something else
already introduced the same changes; you might want to skip this patch.
When you have resolved this problem, run "git rebase --continue".
If you prefer to skip this patch, run "git rebase --skip" instead.
To check out the original branch and stop rebasing, run "git rebase --abort".
I've tried this a number of times. Sometimes with more detailed checks on which branch I'm on, only staging my conflict resolutions but not committing them, and always come back to the same point.
For example, if I abort and don't commit before continuing to rebase, I see the same error:
$ git rebase --abort
$ git status
On branch rebase1
nothing to commit, working tree clean
Now, I see (or believe I do) the same result when I start to rebase
$ git rebase upstream/master
First, rewinding head to replay your work on top of it...
Applying: My Commit Message
Using index info to reconstruct a base tree...
M dir_a/dir_b/dir_c/myfile.py
Falling back to patching base and 3-way merge...
Auto-merging dir_a/dir_b/dir_c/myfile.py
CONFLICT (content): Merge conflict in dir_a/dir_b/dir_c/myfile.py
error: Failed to merge in the changes.
Patch failed at 0001 My Commit Message
The copy of the patch that failed is found in: .git/rebase-apply/patch
When you have resolved this problem, run "git rebase --continue".
If you prefer to skip this patch, run "git rebase --skip" instead.
To check out the original branch and stop rebasing, run "git rebase --abort".
after fixing the conflict I add
and rebase
with the same result:
$ git add dir_a/dir_b/dir_c/myfile.py
$ git rebase --continue
Applying: My Commit Message
Applying: My Commit Message For New Code I want to Rebase
Using index info to reconstruct a base tree...
M dir_a/dir_b/dir_c/myfile.py
Falling back to patching base and 3-way merge...
Auto-merging dir_a/dir_b/dir_c/myfile.py
CONFLICT (content): My Commit Message
error: Failed to merge in the changes.
Patch failed at 0002 Made changes to pass flake8
The copy of the patch that failed is found in: .git/rebase-apply/patch
When you have resolved this problem, run "git rebase --continue".
If you prefer to skip this patch, run "git rebase --skip" instead.
To check out the original branch and stop rebasing, run "git rebase --abort".
What do I need to do/not do to successfully rebase my changes?
You shouldn't commit your changes when resolving rebase conflicts. Once you've done editing the files in order to resolve the conflicts, add your new changes (e.g., git add dir_a/dir_b/dir_c/myfile.py
) and finish the rebase using git rebase --continue
.