I have branch where I have one commit that only modifies whitespace (trailing whitespace and leading whitespace).
I ran git rebase master
and git rebase --ignore-whitespace master
and in both cases I have a merge conflict with the commit that only changed whitespace.
You can run git rebase --skip to completely skip the commit. That means that none of the changes introduced by the problematic commit will be included. It is very rare that you would choose this option. You can fix the conflict.
We use the git diff -w command to ignore all whitespace differences. It will ignore spaces at the beginning, middle, and end of lines.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With