git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: git revert ignore whitespace

From
SSteven <redalert.commander@gmail.com>
Date
Sep 10, 2010, 14:54 UTC
Message-ID
<15732.91.183.48.98.1284130451.squirrel@stevenleeuw.kwik.to>
In-Reply-To
<20100910142114.GB6936@sigill.intra.peff.net>
On Fri, September 10, 2010 16:21, Jeff King wrote:
Show 9 quoted lines
>
> 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

Previous: Jeff KingNext: Jeff King
Message 3 of 5 in “git revert ignore whitespace”
  1. StevenSep 10, 2010
  2. Jeff KingSep 10, 2010
  3. StevenSep 10, 2010
  4. Jeff KingSep 10, 2010
  5. Junio C HamanoSep 10, 2010

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.