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

Re: 'untracked working tree files would be overwritten by merge' on ignored files?

From
Andreas Krey <a.krey@gmx.de>
Date
Jun 14, 2016, 21:35 UTC
Message-ID
<20160614213508.GD30134@inner.h.apk.li>
In-Reply-To
<xmqqy467aeev.fsf@gitster.mtv.corp.google.com>

On Tue, 14 Jun 2016 10:06:16 +0000, Junio C Hamano wrote: ...

Show 5 quoted lines
> 
> IIRC, untracked files are kept during merge and across checking out
> another branch.  Files that are deliberately marked as ignored by
> listing them to .gitignore mechanism are considered expendable, and
> they will be removed as necessary.

Apparently not. Waitaminute - I can check out the other branch, and then the ignored file is replaced by the versioned file there, as you say.

But when I try to merge the other branch, merge complains as in $subject.

That is, 'git merge other' does not work, but 'git checkout out; git checkout -; git merge other' works because then the ignored file is removed in the first checkout and no longer in the way for the merge:

    $ git status --ignored
    On branch side
    Ignored files:
      (use "git add -f <file>..." to include in what will be committed)
	    a.txt
    nothing to commit, working directory clean
    $ git merge master
    error: The following untracked working tree files would be overwritten by merge:
	    a.txt
    Please move or remove them before you can merge.
    Aborting
    $ git checkout master
    Switched to branch 'master'
    $ git checkout -
    Switched to branch 'side'
    $ git merge master
    Merge made by the 'recursive' strategy.
     a.txt | 1 +
     1 file changed, 1 insertion(+)
     create mode 100644 a.txt
    $
Andreas
-- 
"Totally trivial. Famous last words."
From: Linus Torvalds <torvalds@*.org>
Date: Fri, 22 Jan 2010 07:29:21 -0800
Previous: Junio C Hamano
Message 3 of 3 in “'untracked working tree files would be overwritten by merge' on ignored files?”
  1. Andreas KreyJun 14, 2016
  2. Junio C HamanoJun 14, 2016
  3. Andreas KreyJun 14, 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.