{"thread":{"id":"34700","subject":"Bug? ignored files overwritten by checkout","startedAt":"2013-08-15T06:33:11Z","lastAt":"2013-08-15T12:06:58Z","messageCount":2,"participants":["Damien Robert","Jeff King"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"225248","messageId":"kuhsn7$84r$1@ger.gmane.org","threadId":"34700","inReplyTo":null,"subject":"Bug? ignored files overwritten by checkout","fromName":"Damien Robert","fromEmail":"damien.olivier.robert+gmane@gmail.com","sentAt":"2013-08-15T06:33:11Z","receivedAt":"2013-08-15T06:33:11Z","isPatch":false,"sender":{"key":"damien.olivier.robert+gmane@gmail.com","avatar":null},"body":"\ngit init\ngit commit --allow-empty -m \"init\"\ngit checkout -b test\necho foo > foo\ngit add foo\ngit commit -am 'add foo'\ngit checkout master\necho 'Important data' > foo #[1]\necho foo > .gitignore\ngit checkout test\n\nIf I tried a `git checkout test` after [1], I would get the error message \n    error: The following untracked working tree files would be overwritten by checkout: foo\nBut after adding foo to .gitignore, I am able to checkout to branch test\nwithout warning. Of course this overwrites foo to the version in test.\n\nI tested this in version 1.8.3.4 and 1.7.10.4.\n"},{"id":"225259","messageId":"20130815120658.GA22102@sigill.intra.peff.net","threadId":"34700","inReplyTo":"kuhsn7$84r$1@ger.gmane.org","subject":"Re: Bug? ignored files overwritten by checkout","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2013-08-15T12:06:58Z","receivedAt":"2013-08-15T12:06:58Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Thu, Aug 15, 2013 at 06:33:11AM +0000, Damien Robert wrote:\n\n> git init\n> git commit --allow-empty -m \"init\"\n> git checkout -b test\n> echo foo > foo\n> git add foo\n> git commit -am 'add foo'\n> git checkout master\n> echo 'Important data' > foo #[1]\n> echo foo > .gitignore\n> git checkout test\n> \n> If I tried a `git checkout test` after [1], I would get the error message \n>     error: The following untracked working tree files would be overwritten by checkout: foo\n> But after adding foo to .gitignore, I am able to checkout to branch test\n> without warning. Of course this overwrites foo to the version in test.\n\nThis is by design. Marking a file in .gitignore tells git that the\ncontent is not precious and can be removed if need be. For most ignored\nfiles, this is what you want (e.g., you mark \"*.o\" as ignored because it\nis generated; you do not want to add it, and you can always make it\nagain).\n\nThe less common case is a file that is precious and needs to live inside\nyour repository directory, but which you do not want to add (e.g., a\nconfig file that affects your project, but should not ever be\ncommitted).  People have occasionally asked for a .gitignore-like\nmechanism to mark such files as \"precious but do not add\".  However,\nnobody has actually implemented anything.\n\n-Peff\n"}]}