2

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?

user1245262
  • 6,968
  • 8
  • 50
  • 77

3 Answers3

4

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.

Mureinik
  • 297,002
  • 52
  • 306
  • 350
1

I'm including this answer, because it solved the problem I had, though not quite the one I had stated. When I first tried to rebase I did add my changed files without committing them, but without (I believed) any luck when I tried to git rebase --continue. I then tried to commit my changes before executing git rebase --continue, but still unsuccessfully.

My mistake was in not realizing that after fixing one set of conflicts, when I again tried to rebase, new conflicts could arise, which would need to be fixed. When I fixed these new conflicts, I was able to successfully rebase

user1245262
  • 6,968
  • 8
  • 50
  • 77
1

On OSX I had to use git config --global core.trustctime false

See: Git rebase fails, 'Your local changes to the following files would be overwritten by merge'. No local changes?

GeekPete
  • 121
  • 4