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

Re: Invisible file remove during merge

From
Jeff King <peff@peff.net>
Date
Oct 11, 2016, 02:42 UTC
Message-ID
<20161011024204.dg756vuej4rvg4tl@sigill.intra.peff.net>
In-Reply-To
<d7e42701-363b-70a4-8eb0-da4715cd9ba5@alvarezp.ods.org>
On Mon, Oct 10, 2016 at 06:04:26PM -0700, Octavio Alvarez wrote:
> If I do a "git rm file" during conflict resolution, the removed file
> (mysterious-file.txt) does not show up on "git log --stat" nor "git show
> --patch" for the merge commit.

"git log" does not do merge diffs by default; you need to pass one of "--cc", "-c", or "-m".

"git show" will do "--cc" by default. Any file that is the same in the merge result and _any_ of the branches is considered uninteresting here, and that is what happened in your example. One parent had the file, the other did not, and you deleted it to match the second parent.

See the "Combined Diff" section of "git help log" for more details.

When debugging merge resolutions, I often find it useful to use "-m", which diffs separately against _each_ parent (though it is often tedious to pick through the uninteresting bits, which is why "-c" and "--cc" were invented in the first place).

> "git log --all --stat --follow -- mysterious-file.txt" only shows the
> commit where the file was added.

Try that with "-m", which will show the merge in question (and another, more boring merge, which hopefully shows why "-m" is not the default).

-Peff
Previous: Octavio Alvarez
Message 2 of 2 in “Invisible file remove during merge”
  1. Octavio AlvarezOct 11, 2016
  2. Jeff KingOct 11, 2016

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.