{"thread":{"id":"49769","subject":"Checkout deleted semi-untracked file","startedAt":"2018-11-06T12:51:45Z","lastAt":"2018-11-06T15:12:48Z","messageCount":2,"participants":["Steffen Jost","Ævar Arnfjörð Bjarmason"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"362571","messageId":"d4624773-739c-f698-514d-458ce2ef5503@tcs.ifi.lmu.de","threadId":"49769","inReplyTo":null,"subject":"Checkout deleted semi-untracked file","fromName":"Steffen Jost","fromEmail":"jost@tcs.ifi.lmu.de","sentAt":"2018-11-06T12:41:53Z","receivedAt":"2018-11-06T12:51:45Z","isPatch":false,"sender":{"key":"jost@tcs.ifi.lmu.de","avatar":null},"body":"Hello!\n\nA brief discussion on the git user mailing list on Google Groups recommended me to file the following as a bug report.\n\nThe problem led to an actual file loss, but I suspect that this might be intended:\n\n1) .gitignore is added to the repository (which then causes problems)\n2) A file is added, repeatedly edited and comitted to a remote repository.\n3) Later on, the file is added to .gitignore and \"git rm --cached file\" is executed (since the file now contains information private to each developer).\n4) Several commits happen.\n5) I checkout an old branch which has not yet seen the change in .gitignore in the master branch. The file is reverted to the state of the branch.\n6) I checkout master, and the file with all later changes is irrevocably lost.\n\nI usually advise my students to check-in their .gitignore file into the repository. Apparently this is a bad advice, since it now led to a somewhat painful file loss for me.\n\nSo what is the actual advice on this? Google turned up mixed advice there, and the git user mailing list on Google Groups recommended me submitting this as a bug here. However, I think this works as intended. However, I don't know either how to avert this problem, apart from not checking in the .gitignore file (or checking it in under a different name and copying it manually).\n\n\nThanks for any advice,\n  Steffen Jost.\n\n-- \n+49-89-2180-9139\nhttp://www.tcs.ifi.lmu.de/~jost/\n\nLehr- und Forschungseinheit für Theoretische Informatik\nLudwig-Maximilians-Universität München\nOettingenstr. 67 (E111)\n80538 München\nBAVARIA\n"},{"id":"362579","messageId":"875zxa6xzp.fsf@evledraar.gmail.com","threadId":"49769","inReplyTo":"d4624773-739c-f698-514d-458ce2ef5503@tcs.ifi.lmu.de","subject":"Re: Checkout deleted semi-untracked file","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2018-11-06T15:12:42Z","receivedAt":"2018-11-06T15:12:48Z","isPatch":false,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"\nOn Tue, Nov 06 2018, Steffen Jost wrote:\n\n> Hello!\n>\n> A brief discussion on the git user mailing list on Google Groups recommended me to file the following as a bug report.\n>\n> The problem led to an actual file loss, but I suspect that this might be intended:\n>\n> 1) .gitignore is added to the repository (which then causes problems)\n> 2) A file is added, repeatedly edited and comitted to a remote repository.\n> 3) Later on, the file is added to .gitignore and \"git rm --cached file\" is executed (since the file now contains information private to each developer).\n> 4) Several commits happen.\n> 5) I checkout an old branch which has not yet seen the change in .gitignore in the master branch. The file is reverted to the state of the branch.\n> 6) I checkout master, and the file with all later changes is irrevocably lost.\n>\n> I usually advise my students to check-in their .gitignore file into the repository. Apparently this is a bad advice, since it now led to a somewhat painful file loss for me.\n>\n> So what is the actual advice on this? Google turned up mixed advice there, and the git user mailing list on Google Groups recommended me submitting this as a bug here. However, I think this works as intended. However, I don't know either how to avert this problem, apart from not checking in the .gitignore file (or checking it in under a different name and copying it manually).\n\nThis recent thread should be a good starting point:\nhttps://public-inbox.org/git/4C6A1C5B.4030304@workspacewhiz.com/\n\nMy reply here I think has an overview of some of the caveats:\nhttps://public-inbox.org/git/871s8qdzph.fsf@evledraar.gmail.com/\n\ntl;dr: Git assumes that a pattern in .gitignore means you don't care\nabout the contents, since it's meant for *.o and the like. This leads to\ndata loss in some situations (such as yours).\n\nVarious suggestions in that thread of ways forward, but none have\nbeen implemented>\n"}]}