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

Re: git revert ignore whitespace

From
Jeff King <peff@peff.net>
Date
Sep 10, 2010, 14:21 UTC
Message-ID
<20100910142114.GB6936@sigill.intra.peff.net>
In-Reply-To
<14756.91.183.48.98.1284105472.squirrel@stevenleeuw.kwik.to>
On Fri, Sep 10, 2010 at 09:57:52AM +0200, Steven wrote:
> I want to revert a specific commit using 'git revert',
> however in the meantime there were some whitespace changes.
> Is it still possible to do this? The manual doesn't mention a -w or
> --ignore-whitespace option for git revert.

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`'"

which is more or less what revert will do (actually, I think it will do more with 3-way merges during the application, but the point is that a revert in git is nothing more than achieving a tree state that pulls out the reverted content, and then making a commit. It has no special status in the history graph).

-Peff
Previous: StevenNext: Steven
Message 2 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.