Reputation: 5278
I know that there is a -X ignore-all-space
option for git merge
. However, is it possible to ignore whitespace conflicts for git stash pop
after a rebase
? Or for git rebase
itself?
I did:
git stash
to save local changesgit rebase master
git stash pop
- and got loads of whitespace conflicts that are very hard to resolve since whole files are shown as conflicts, although it's only some whitespace that changed.Upvotes: 1
Views: 170
Reputation: 60295
Tinkering with the innards is kind of what Git's there for. Stash exists because it's a bit fiddly, but it's not rocket science.
From your new tip where you want to merge the old stash, including work tree and index differences:
git cherry-pick -nm1 stash^2 -Xignore-space-change
index=`git write-tree`
git cherry-pick -nm2 stash -Xignore-space-change
git read-tree $index
git stash drop
Why this sequence? You have:
B'--*---T' your-rebased-tip
B---*---T
`-----Sw stash
`-Sx/
Assuming you didn't turn any knobs (like also stashing untracked files, you can do that, if you did, you get to figure it out, it's not hard), your stash is a commit of your old work tree with a commit of your old index as its second parent. That's really all there is to it.
This isn't in any material way an abstract drawing of what's going on, that's about as close as ascii art can get to the literal, actual data structure Git manipulates. There's nothing left out, there's no hidden complexities, that's it. Every node in that dag is a full snapshot. You want to merge the differences from T
to Sx
to your new index, and the differences from Sx
to Sw
to the result of that merge, then restore the index to those results (since merge uses the index to keep track of what's going on with your content same as you and the rest of Git do).
Upvotes: 1