Thread (4 messages) 4 messages, 2 authors, 2016-06-15

Re: git revert ignore whitespace

flat view

From: Steven <hidden>
Date: 2016-06-15 22:49:31

On Fri, September 10, 2010 16:21, Jeff King wrote:
In theory there is no reason we couldn't support "-w", but I don't think
there is a way to do it currently.

You could just manually do the revert. Something like:

  git diff-tree -p $commit | git apply --ignore-whitespace
  git commit -m "revert '`git log -1 --format=%s $commit`'"
Thanks for the tip Jeff.

I had to modify the commands a bit to get it to work.
Here they are:
git diff-tree -p <commithash> | git apply --reverse --ignore-whitespace -C0
git add <file(s)>
git commit -m "revert '`git log -1 --format=%s $commit`'"

The --reverse is necessary to revert a patch, I needed the -C0 parameter
as well because the line above changed as well.
This was a fairly simple example, but I imagine it won't work at all with
a larger history, especially with more changes in the relevant sections
and additions/deletions. I believe git revert does take these into
account?

Kind regards,
Steven
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help