Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

git rebase failing due to whitespace error

Tags:

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.

like image 579
melder Avatar asked Nov 19 '12 22:11

melder


People also ask

What is whitespace error in git?

What are considered whitespace errors is controlled by core. whitespace configuration. By default, trailing whitespaces (including lines that solely consist of whitespaces) and a space character that is immediately followed by a tab character inside the initial indent of the line are considered whitespace errors.

How to remove whitespace from git patch?

UPDATE: You can use “git am –reject –whitespace=fix filename. patch” then it will fix the blank lines and trailing whitespaces and you don't need to run “git add” and “git commit”!

What is a whitespace error?

Whitespace error can be caused by either an unsupported character or symbol being passed to the gateway, or a blank or white space being left in a field. Most commonly, the Whitespace error is caused by characters or symbols that are not supported by global XML code being passed to the gateway.

What is rebase error?

If you type git rebase --continue. you realize the error is because of a merge conflict that git cannot resolve by itself, and needs your help. To see what files have conflicts, type git status. Resolve the merge conflicts in your favorite editor/IDE (hint: this should start with i and end with ntelliJ)


1 Answers

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.

like image 98
joanpau Avatar answered Sep 17 '22 21:09

joanpau