{"thread":{"id":"54386","subject":"[BUG?] After 'git checkout', files deleted upstream are left in the working directory as untracked","startedAt":"2020-10-10T23:10:48Z","lastAt":"2020-10-12T11:10:05Z","messageCount":4,"participants":["Philippe Blain","Johannes Sixt","Johannes Schindelin"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"407282","messageId":"3D3C5F5D-830E-4EC7-A527-DC595D983BB2@gmail.com","threadId":"54386","inReplyTo":null,"subject":"[BUG?] After 'git checkout', files deleted upstream are left in the working directory as untracked","fromName":"Philippe Blain","fromEmail":"levraiphilippeblain@gmail.com","sentAt":"2020-10-10T16:43:10Z","receivedAt":"2020-10-10T23:10:48Z","isPatch":false,"sender":{"key":"levraiphilippeblain@gmail.com","avatar":"https://avatars.githubusercontent.com/u/44212482?v=4"},"body":"Hello all,\n\nI've noticed a weird behaviour of 'git checkout' and I don't know if it's a bug.\n\nI went back to an old clone which had an old feature branch ('stale-branch') \ncheckout out, and its working directory and index matching HEAD \n('git status' is clean).\nThen I did `git checkout other-branch`, where 'other branch' is a more \nrecent feature branch, based on a more recent commit on 'master'.\nAfter the checkout, `git status` reports untracked files. These are files that were \ndeleted on 'master' between the commit on which 'stale-branch' was based (d9f6f3b619)\nand the commit on which 'other-branch' is based (d4a392452e).\n\nThe thing is, I can't reproduce it on a fresh clone. If I could, this would be a reproducer:\n\n```\n$ git clone git@github.com:phil-blain/git.git && cd git\n$ git checkout stale-branch\n$ git checkout other-branch\n$ git status # the following is what is shown in my old clone\nOn branch other-branch\nUntracked files:\n  (use \"git add <file>...\" to include in what will be committed)\n\n\tgit-legacy-stash\n\tgit-remote-testsvn\n\tt/helper/test-line-buffer\n\tt/helper/test-svn-fe\n\nnothing added to commit but untracked files present (use \"git add\" to track)\n```\n\nI did not modify or delete any of these 4 files myself, neither in the commits \non 'stale-branch' or in the commits on 'other-branch'. They were deleted by\nother feature branches that were merged to 'master' between d9f6f3b619 and\nd4a392452e.\n\nThis is not the first time that I've seen this happen, and I'd like to understand\nif this is a bug, and why I can't reproduce it on a fresh clone (I'm guessing maybe\nthe index is at play here, but I'm not sure how to diagnose it)...\n\nThanks and cheers,\n\nPhilippe.\n\n"},{"id":"407292","messageId":"8f88733f-4f20-6215-00a8-de3024b8c4cb@kdbg.org","threadId":"54386","inReplyTo":"3D3C5F5D-830E-4EC7-A527-DC595D983BB2@gmail.com","subject":"Re: [BUG?] After 'git checkout', files deleted upstream are left in the working directory as untracked","fromName":"Johannes Sixt","fromEmail":"j6t@kdbg.org","sentAt":"2020-10-11T06:58:48Z","receivedAt":"2020-10-11T06:58:54Z","isPatch":false,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"Am 10.10.20 um 18:43 schrieb Philippe Blain:\n> The thing is, I can't reproduce it on a fresh clone. If I could, this would be a reproducer:\n> \n> ```\n> $ git clone git@github.com:phil-blain/git.git && cd git\n> $ git checkout stale-branch\n> $ git checkout other-branch\n> $ git status # the following is what is shown in my old clone\n> On branch other-branch\n> Untracked files:\n>   (use \"git add <file>...\" to include in what will be committed)\n> \n> \tgit-legacy-stash\n> \tgit-remote-testsvn\n> \tt/helper/test-line-buffer\n> \tt/helper/test-svn-fe\n> \n> nothing added to commit but untracked files present (use \"git add\" to track)\n> ```\n\nThis is normal. These 4 files are build products and were never\ncommitted files. They had been mentioned in .gitignore in the past, but\nare not anymore.\n\nApparently, your old repository had these build products still lying\naround. If you insert `make` in your instructions above after `git\ncheckout stale-branch`, you should be able to observe the same\nun-cleanlyness in a new clone.\n\n-- Hannes\n"},{"id":"407306","messageId":"7F30E2AB-D742-4581-9AF8-6138A45A3F22@gmail.com","threadId":"54386","inReplyTo":"8f88733f-4f20-6215-00a8-de3024b8c4cb@kdbg.org","subject":"Re: [BUG?] After 'git checkout', files deleted upstream are left in the working directory as untracked","fromName":"Philippe Blain","fromEmail":"levraiphilippeblain@gmail.com","sentAt":"2020-10-11T16:19:17Z","receivedAt":"2020-10-11T16:20:58Z","isPatch":false,"sender":{"key":"levraiphilippeblain@gmail.com","avatar":"https://avatars.githubusercontent.com/u/44212482?v=4"},"body":"Hi Johannes, \n\n> Le 11 oct. 2020 à 02:58, Johannes Sixt <j6t@kdbg.org> a écrit :\n> \n> Am 10.10.20 um 18:43 schrieb Philippe Blain:\n>> The thing is, I can't reproduce it on a fresh clone. If I could, this would be a reproducer:\n>> \n>> ```\n>> $ git clone git@github.com:phil-blain/git.git && cd git\n>> $ git checkout stale-branch\n>> $ git checkout other-branch\n>> $ git status # the following is what is shown in my old clone\n>> On branch other-branch\n>> Untracked files:\n>>  (use \"git add <file>...\" to include in what will be committed)\n>> \n>> \tgit-legacy-stash\n>> \tgit-remote-testsvn\n>> \tt/helper/test-line-buffer\n>> \tt/helper/test-svn-fe\n>> \n>> nothing added to commit but untracked files present (use \"git add\" to track)\n>> ```\n> \n> This is normal. These 4 files are build products and were never\n> committed files. They had been mentioned in .gitignore in the past, but\n> are not anymore.\n\nOops, I should've checked that. Thanks for answering!\n\nPhilippe.\n\n"},{"id":"407324","messageId":"nycvar.QRO.7.76.6.2010121306470.50@tvgsbejvaqbjf.bet","threadId":"54386","inReplyTo":"3D3C5F5D-830E-4EC7-A527-DC595D983BB2@gmail.com","subject":"Re: [BUG?] After 'git checkout', files deleted upstream are left in the working directory as untracked","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2020-10-12T11:10:00Z","receivedAt":"2020-10-12T11:10:05Z","isPatch":false,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi Philippe,\n\nOn Sat, 10 Oct 2020, Philippe Blain wrote:\n\n> $ git status # the following is what is shown in my old clone\n> On branch other-branch\n> Untracked files:\n>   (use \"git add <file>...\" to include in what will be committed)\n>\n> \tgit-legacy-stash\n> \tgit-remote-testsvn\n> \tt/helper/test-line-buffer\n> \tt/helper/test-svn-fe\n\nThese files were generated previously, but are no longer generated\n(`legacy-stash` was retired in favor of the built-in `stash`,\n`remote-testsvn` was dropped because it languished for long enough without\nanybody picking it back up, and the test helpers were necessary to test\n`test-svn`).\n\nSince they are no longer generated, those build products are no longer\ndesired.\n\nAnd you don't see them in a fresh clone because they were only compiled in\nprevious revisions.\n\nSo this works as expected.\n\nWhat you will want to do is to run `git clean -dn` to see what `clean`\nwould remove, and once satisfied that it's all good, actually remove the\nfiles using `git clean -df`.\n\nCiao,\nDscho\n"}]}