git rebase failing due to whitespace error git rebase failing due to whitespace error git git

git rebase failing due to whitespace error


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.


that will not side step the issue. You now have conflict markers in your file!

The whitespace issue are warnings and you should not have as many legitimate conflicts. If the file is a nightmare to resolve, you may need to reconstruct it by hand. This depends on what you're doing though.

Many times the two bases are so different that each commit you are rebasing make you deal with this monstrous conflict. I tend to steer clear of rebase workflows and subscribe to merge/reset. Here's what I do: http://dymitruk.com/blog/2012/02/05/branch-per-feature/

If your issues are only whitespace problems like line endings, you can try and clean up your repository by doing a filter branch or an interactive rebase on each side first to get whitespace on each commit to be consistent.

Also I use beyond compare 3 or Perforce Merge to do conflict resolutions. BC3 is syntax aware and should deal with whitespace the best. A lot of times, it won't even open up as it will resolve the conflicts for you and you can just continue.


Today I solved such a problem this way:

REMOVE_AFTER="3cd7a0db76ff9dca48979e24c39b408c"REPO="git@github.com:company/repo.git"cd ~/tmpgit clone $REPO gitfixcd gitfixgit checkout --orphan temp $REMOVE_AFTERgit commit -m "Truncated history"git rebase --strategy=recursive --strategy-option=theirs --onto temp $REMOVE_AFTER master

When during the rebase you get a CONFLICT (modify/delete) conflict which is caused by a deleted file, you can solve it this way:

git rm path/to/both/deleted/filegit rebase --continue

When during the rebase you get an other conflict, you will need to manually fix it, and afterwards:

git add path/to/conflict/filegit rebase --continue

When you are finished, the rebase says All done. Then you can:

git branch -D temp

Now check the result:

git log --format=oneline