How to run git rebase and ignore whitespace?
I can't guarantee that this will help, but you could trygit rebase -Xignore-space-change master
orgit rebase -Xignore-all-space master
.-X
passes options into the merge algorithm, and the default merge algorithm has these options to affect how it handles whitespace.
This is easier with Git 2.29 (Q4 2020)
"git rebase -i
"(man)learns a bit more options, including --ignore-whitespace
on merge (which was not supported in 2014 when the OP used that option).
So git rebase --ignore-whitespace master
will now work!
See commit 6160b2e (26 Aug 2020) by Junio C Hamano (gitster
).
See commit 2712669 (17 Aug 2020), and commit ef484ad (13 Jul 2020) by Rohit Ashiwal (r1walz
).
See commit a3894aa, commit 7573cec, commit e8cbe21 (17 Aug 2020) by Phillip Wood (phillipwood
).
(Merged by Junio C Hamano -- gitster
-- in commit 9c31b19, 03 Sep 2020)
rebase -i
: add --ignore-whitespace flagSigned-off-by: Rohit Ashiwal
Signed-off-by: Phillip Wood
Rebase is implemented with two different backends - '
apply
' and 'merge
' each of which support a different set of options.In particular the
apply
backend supports a number of options implemented by 'git am
(man) ' that are not implemented in themerge
backend.This means that the available options are different depending on which backend is used which is confusing.
This patch adds support for the
--ignore-whitespace
option to themerge
backend.
This option treats lines with only whitespace changes as unchanged and is implemented in the merge backend by translating it to-Xignore-space-change
.
git rebase
now includes in its man page:
--ignore-whitespace
:Ignore whitespace differences when trying to reconcile differences.
Currently, each backend implements an approximation of this behavior:
apply
backend: When applying a patch, ignore changes in whitespace in context lines. Unfortunately, this means that if the "old" lines being replaced by the patch differ only in whitespace from the existing file, you will get a merge conflict instead of a successful patch application.
merge
backend: Treat lines with only whitespace changes as unchanged when merging.
Unfortunately, this means that any patch hunks that were intended to modify whitespace and nothing else will be dropped, even if the other side had no changes that conflicted.This flag is passed to the '
git apply
' program