git rebase failing due to whitespace error

melder picture melder · Nov 19, 2012 · Viewed 18.3k times · Source

I'm trying to rebase a branch and git is pooping out because it's attempting to perform some merge action which fails. How do I get git to stop this?

# git rebase -f --onto master~2 master~ master
First, rewinding head to replay your work on top of it...
Applying: r1002 - CS 1.0.23
Using index info to reconstruct a base tree...
M   about.html
<stdin>:68: trailing whitespace.                     
<stdin>:115: trailing whitespace.
<stdin>:201: trailing whitespace.
<stdin>:2369: trailing whitespace.
<stdin>:2385: trailing whitespace.
warning: squelched 2305 whitespace errors
warning: 2310 lines add whitespace errors.
Falling back to patching base and 3-way merge...
Auto-merging about.html
CONFLICT (content): Merge conflict in about.html
Failed to merge in the changes.
Patch failed at 0001 r1002 - 1002
The copy of the patch that failed is found in:
   /local/melder/tmp/test/.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".

As you can see there are 2000+ whitespace errors, not something easy to merge by hand.

Edit: to side step this for now without merging I did:

# git add -A
# git rebase --continue

Edit: nevermind that is a silly idea.

Answer

joanpau picture joanpau · Mar 5, 2015

I faced the same problem today: rebase fails due to conflicts caused by whitespace errors. After failed trials with different settings for the whitespace option (git rebase --whitespace=fix and git rebase --whitespace=nowarn), the solution that worked for me was to ignore trailing whitespace errors in the recursive merging strategy (git rebase --abort any running rebase first if needed):

git rebase -Xignore-space-at-eol <newbase>

Depenending on the kind of whitespace errors, options -Xignore-space-change and -Xignore-all-space might be more useful. I don't know if the option --ignore-whitespace would have also worked.