{"thread":{"id":"42608","subject":"'untracked working tree files would be overwritten by merge' on ignored files?","startedAt":"2016-06-16T06:55:52Z","lastAt":"2016-06-16T06:55:52Z","messageCount":3,"participants":["Andreas Krey","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"289224","messageId":"20160614160720.GA22675@inner.h.apk.li","threadId":"42608","inReplyTo":null,"subject":"'untracked working tree files would be overwritten by merge' on ignored files?","fromName":"Andreas Krey","fromEmail":"a.krey@gmx.de","sentAt":"2016-06-14T16:07:20Z","receivedAt":"2016-06-16T06:55:52Z","isPatch":false,"sender":{"key":"a.krey@gmx.de","avatar":"https://avatars.githubusercontent.com/u/37810?v=4"},"body":"Hi all,\n\nwhen I have an ignored file in my workspace, is git\nthen also assumed not to remove it in the course\nof a merge?\n\nShouldn't it then say that the file is ignored,\nas it does not show up in the untracked section\nof git status?\n\nRegards, Andreas\n\nPS: Test script (will remove anything named 'tst'):\n    rm -rf tst\n    mkdir tst\n    cd tst || exit 1\n    git init\n    echo '*.txt' >.gitignore\n    git add .\n    git commit -m initial\n    git checkout -b side\n    git checkout -\n    date >a.txt\n    git add -f a.txt\n    git commit -m 'new file'\n    git checkout side\n    git commit -m 'nix' --allow-empty\n    touch a.txt\n    git status --ignored    # Shows a.txt as ignored\n    git merge master        # Will complain\n    git version\n\n-- \n\"Totally trivial. Famous last words.\"\nFrom: Linus Torvalds <torvalds@*.org>\nDate: Fri, 22 Jan 2010 07:29:21 -0800\n"},{"id":"289228","messageId":"xmqqy467aeev.fsf@gitster.mtv.corp.google.com","threadId":"42608","inReplyTo":"20160614160720.GA22675@inner.h.apk.li","subject":"Re: 'untracked working tree files would be overwritten by merge' on ignored files?","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2016-06-14T17:06:16Z","receivedAt":"2016-06-16T06:55:52Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Andreas Krey <a.krey@gmx.de> writes:\n\n> when I have an ignored file in my workspace, is git\n> then also assumed not to remove it in the course\n> of a merge?\n\nIIRC, untracked files are kept during merge and across checking out\nanother branch.  Files that are deliberately marked as ignored by\nlisting them to .gitignore mechanism are considered expendable, and\nthey will be removed as necessary.\n\nThis is because we do not have the fourth-class, \"we do not want to\nadd them to the history as tracked contents, but we do not want to\nlose them\", aka \"precious\"; we only have three, i.e. \"paths in the\nindex\", \"path that are untracked\" and \"path that are ignored\".\n"},{"id":"289254","messageId":"20160614213508.GD30134@inner.h.apk.li","threadId":"42608","inReplyTo":"xmqqy467aeev.fsf@gitster.mtv.corp.google.com","subject":"Re: 'untracked working tree files would be overwritten by merge' on ignored files?","fromName":"Andreas Krey","fromEmail":"a.krey@gmx.de","sentAt":"2016-06-14T21:35:08Z","receivedAt":"2016-06-16T06:55:52Z","isPatch":false,"sender":{"key":"a.krey@gmx.de","avatar":"https://avatars.githubusercontent.com/u/37810?v=4"},"body":"On Tue, 14 Jun 2016 10:06:16 +0000, Junio C Hamano wrote:\n...\n> \n> IIRC, untracked files are kept during merge and across checking out\n> another branch.  Files that are deliberately marked as ignored by\n> listing them to .gitignore mechanism are considered expendable, and\n> they will be removed as necessary.\n\nApparently not. Waitaminute - I can check out the other branch,\nand then the ignored file is replaced by the versioned file there,\nas you say.\n\nBut when I try to merge the other branch, merge complains as in $subject.\n\nThat is, 'git merge other' does not work, but 'git checkout out;\ngit checkout -; git merge other' works because then the ignored file is\nremoved in the first checkout and no longer in the way for the merge:\n\n    $ git status --ignored\n    On branch side\n    Ignored files:\n      (use \"git add -f <file>...\" to include in what will be committed)\n\n\t    a.txt\n\n    nothing to commit, working directory clean\n    $ git merge master\n    error: The following untracked working tree files would be overwritten by merge:\n\t    a.txt\n    Please move or remove them before you can merge.\n    Aborting\n    $ git checkout master\n    Switched to branch 'master'\n    $ git checkout -\n    Switched to branch 'side'\n    $ git merge master\n    Merge made by the 'recursive' strategy.\n     a.txt | 1 +\n     1 file changed, 1 insertion(+)\n     create mode 100644 a.txt\n    $\n\nAndreas\n\n-- \n\"Totally trivial. Famous last words.\"\nFrom: Linus Torvalds <torvalds@*.org>\nDate: Fri, 22 Jan 2010 07:29:21 -0800\n"}]}