Git development
 help / color / mirror / Atom feed
* 'untracked working tree files would be overwritten by merge' on ignored files?
@ 2016-06-14 16:07 Andreas Krey
  2016-06-14 17:06 ` Junio C Hamano
  0 siblings, 1 reply; 3+ messages in thread
From: Andreas Krey @ 2016-06-14 16:07 UTC (permalink / raw)
  To: git

Hi all,

when I have an ignored file in my workspace, is git
then also assumed not to remove it in the course
of a merge?

Shouldn't it then say that the file is ignored,
as it does not show up in the untracked section
of git status?

Regards, Andreas

PS: Test script (will remove anything named 'tst'):
    rm -rf tst
    mkdir tst
    cd tst || exit 1
    git init
    echo '*.txt' >.gitignore
    git add .
    git commit -m initial
    git checkout -b side
    git checkout -
    date >a.txt
    git add -f a.txt
    git commit -m 'new file'
    git checkout side
    git commit -m 'nix' --allow-empty
    touch a.txt
    git status --ignored    # Shows a.txt as ignored
    git merge master        # Will complain
    git version

-- 
"Totally trivial. Famous last words."
From: Linus Torvalds <torvalds@*.org>
Date: Fri, 22 Jan 2010 07:29:21 -0800

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: 'untracked working tree files would be overwritten by merge' on ignored files?
  2016-06-14 16:07 'untracked working tree files would be overwritten by merge' on ignored files? Andreas Krey
@ 2016-06-14 17:06 ` Junio C Hamano
  2016-06-14 21:35   ` Andreas Krey
  0 siblings, 1 reply; 3+ messages in thread
From: Junio C Hamano @ 2016-06-14 17:06 UTC (permalink / raw)
  To: Andreas Krey; +Cc: git

Andreas Krey <a.krey@gmx.de> writes:

> when I have an ignored file in my workspace, is git
> then also assumed not to remove it in the course
> of a merge?

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.

This is because we do not have the fourth-class, "we do not want to
add them to the history as tracked contents, but we do not want to
lose them", aka "precious"; we only have three, i.e. "paths in the
index", "path that are untracked" and "path that are ignored".

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: 'untracked working tree files would be overwritten by merge' on ignored files?
  2016-06-14 17:06 ` Junio C Hamano
@ 2016-06-14 21:35   ` Andreas Krey
  0 siblings, 0 replies; 3+ messages in thread
From: Andreas Krey @ 2016-06-14 21:35 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git

On Tue, 14 Jun 2016 10:06:16 +0000, Junio C Hamano wrote:
...
> 
> 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

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-06-14 21:35 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-06-14 16:07 'untracked working tree files would be overwritten by merge' on ignored files? Andreas Krey
2016-06-14 17:06 ` Junio C Hamano
2016-06-14 21:35   ` Andreas Krey

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox