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

"fatal: Untracked working tree file 'so-and-so' would be overwritten by merge"

From
Linus Torvalds <torvalds@osdl.org>
Date
Oct 9, 2006, 00:11 UTC
Message-ID
<Pine.LNX.4.64.0610081657400.3952@g5.osdl.org>

Hmm. I'm getting this message annoyingly often, simply because a few files that used to be tracked are now generated, and so they exist in my tree but are no longer tracked.

However, they may be tracked in an older tree that I pull, because in that older tree they _do_ exist, and we get the

	fatal: Untracked working tree file 'so-and-so' would be overwritten by merge.

which is actually incorrect, because the merge result will not even _contain_ that untracked file any more.

So the message is misleading - we should only consider this a fatal thing if we actually do generate that file as part of a git-read-tree, but if a merge won't touch a file, it shouldn't be "overwritten".

It's true that if the _other_ end actually removed a file that we used to have (ie the file _disappears_ as part of the merge), then we should verify that that file matched what we're going to remove, but if the old index didn't contain the file at all, and the new index won't contain it either, it really should be a no-op.

IOW, I think there is one "verify_absent()" too many somewhere, where we check this unnecessarily. I think it's the one in "deleted_entry()" in unpack-trees.c, but I'm not sure.

		Linus
Next: Junio C Hamano
Message 1 of 12 in “"fatal: Untracked working tree file 'so-and-so' would be overwritten by merge"”
  1. Linus TorvaldsOct 9, 2006
  2. Junio C HamanoOct 9, 2006
  3. Junio C HamanoOct 9, 2006
  4. merge: loosen overcautious "working file will be lost" check.Junio C Hamano, Oct 9, 2006
  5. Luben TuikovOct 9, 2006
  6. Junio C HamanoOct 9, 2006
  7. Luben TuikovOct 10, 2006
  8. Junio C HamanoOct 10, 2006
  9. Luben TuikovOct 10, 2006
  10. Linus TorvaldsOct 9, 2006
  11. Junio C HamanoOct 9, 2006
  12. Junio C HamanoOct 10, 2006

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.