{"thread":{"id":"21984","subject":"How to exclude files from \"git diff\"","startedAt":"2009-12-18T17:09:15Z","lastAt":"2010-01-05T18:41:03Z","messageCount":7,"participants":["H.J. Lu","Jeff King","Dmitry Potapov","Nguyen Thai Ngoc Duy","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"130079","messageId":"6dc9ffc80912180909q2e9cbe30r7c802a2152c5954@mail.gmail.com","threadId":"21984","inReplyTo":null,"subject":"How to exclude files from \"git diff\"","fromName":"H.J. Lu","fromEmail":"hjl.tools@gmail.com","sentAt":"2009-12-18T17:09:15Z","receivedAt":"2009-12-18T17:09:15Z","isPatch":false,"sender":{"key":"hjl.tools@gmail.com","avatar":null},"body":"Hi,\n\nI have some bookkeeping files in my git repository.  How do I\nexclude them from \"git diff\"? Does \"git diff\" support\n\n# git diff --exclude=\"foo.*.bar*\"\n\nPlease CC me since I am not on the git mailing list.\n\nThanks.\n\n\n-- \nH.J.\n"},{"id":"130823","messageId":"20100105064509.GC19025@coredump.intra.peff.net","threadId":"21984","inReplyTo":"6dc9ffc80912180909q2e9cbe30r7c802a2152c5954@mail.gmail.com","subject":"Re: How to exclude files from \"git diff\"","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2010-01-05T06:45:09Z","receivedAt":"2010-01-05T06:45:09Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Fri, Dec 18, 2009 at 09:09:15AM -0800, H.J. Lu wrote:\n\n> I have some bookkeeping files in my git repository.  How do I\n> exclude them from \"git diff\"? Does \"git diff\" support\n> \n> # git diff --exclude=\"foo.*.bar*\"\n\nNo, I don't believe there is a way to do that. You would have to do\nsomething like:\n\n  git diff $(git ls-files | grep -v whatever)\n\nThe usual concept of \"exclusion\" for git is not to track files at all\nvia the .gitignore mechanism.  Are these files that have content you\nreally _want_ in the repository, but you just don't want to see them\nwhen doing some diffs? Or are they files that could not be in the\nrepository at all?\n\n-Peff\n"},{"id":"130843","messageId":"6dc9ffc81001050620q55c23072p93f58c8685d77f9d@mail.gmail.com","threadId":"21984","inReplyTo":"20100105064509.GC19025@coredump.intra.peff.net","subject":"Re: How to exclude files from \"git diff\"","fromName":"H.J. Lu","fromEmail":"hjl.tools@gmail.com","sentAt":"2010-01-05T14:20:15Z","receivedAt":"2010-01-05T14:20:15Z","isPatch":false,"sender":{"key":"hjl.tools@gmail.com","avatar":null},"body":"On Mon, Jan 4, 2010 at 10:45 PM, Jeff King <peff@peff.net> wrote:\n> On Fri, Dec 18, 2009 at 09:09:15AM -0800, H.J. Lu wrote:\n>\n>> I have some bookkeeping files in my git repository.  How do I\n>> exclude them from \"git diff\"? Does \"git diff\" support\n>>\n>> # git diff --exclude=\"foo.*.bar*\"\n>\n> No, I don't believe there is a way to do that. You would have to do\n> something like:\n>\n>  git diff $(git ls-files | grep -v whatever)\n>\n> The usual concept of \"exclusion\" for git is not to track files at all\n> via the .gitignore mechanism.  Are these files that have content you\n> really _want_ in the repository, but you just don't want to see them\n> when doing some diffs? Or are they files that could not be in the\n> repository at all?\n\nYes, I want those files in repository. They are for my personal use only.\n\nThanks.\n\n-- \nH.J.\n"},{"id":"130849","messageId":"37fcd2781001050954y778ba661n7cee6cda699968c2@mail.gmail.com","threadId":"21984","inReplyTo":"6dc9ffc81001050620q55c23072p93f58c8685d77f9d@mail.gmail.com","subject":"Re: How to exclude files from \"git diff\"","fromName":"Dmitry Potapov","fromEmail":"dpotapov@gmail.com","sentAt":"2010-01-05T17:54:08Z","receivedAt":"2010-01-05T17:54:08Z","isPatch":false,"sender":{"key":"dpotapov@gmail.com","avatar":"https://avatars.githubusercontent.com/u/6568595?v=4"},"body":"On Tue, Jan 5, 2010 at 5:20 PM, H.J. Lu <hjl.tools@gmail.com> wrote:\n>\n> Yes, I want those files in repository. They are for my personal use only.\n\nIf you modified some file locally and do not want to see and commit\nthose modifications, you may want to use:\n\ngit update-index --assume-unchanged foo\n\nAfter that, git will not notice any change to `foo'. So, 'git diff' and any\nother command (such git commit -a) will ignore those changes.\n\nWarning: using  --assume-unchanged may result in losing your changes\nif you switch between branches containing different versions of 'foo'.\n\nNormally, when you try to do that, git will not allow switch to another\nbranch saying that `foo' is modified. But using --assume-unchanged\ndisables this check. But if you have the same `foo' on all branches\nthen switching between branches will preserve your modifications.\n\n\nDmitry\n"},{"id":"130850","messageId":"6dc9ffc81001051015x3bebc994r3d475bdb59e12d39@mail.gmail.com","threadId":"21984","inReplyTo":"37fcd2781001050954y778ba661n7cee6cda699968c2@mail.gmail.com","subject":"Re: How to exclude files from \"git diff\"","fromName":"H.J. Lu","fromEmail":"hjl.tools@gmail.com","sentAt":"2010-01-05T18:15:19Z","receivedAt":"2010-01-05T18:15:19Z","isPatch":false,"sender":{"key":"hjl.tools@gmail.com","avatar":null},"body":"On Tue, Jan 5, 2010 at 9:54 AM, Dmitry Potapov <dpotapov@gmail.com> wrote:\n> On Tue, Jan 5, 2010 at 5:20 PM, H.J. Lu <hjl.tools@gmail.com> wrote:\n>>\n>> Yes, I want those files in repository. They are for my personal use only.\n>\n> If you modified some file locally and do not want to see and commit\n> those modifications, you may want to use:\n>\n> git update-index --assume-unchanged foo\n>\n\nI added those files into my repository for bookkeeping purpose. It\nshouldn't go out at all.\n\n\n-- \nH.J.\n"},{"id":"130852","messageId":"fcaeb9bf1001051031j6723dc14v8d43944e3b8baa90@mail.gmail.com","threadId":"21984","inReplyTo":"6dc9ffc81001051015x3bebc994r3d475bdb59e12d39@mail.gmail.com","subject":"Re: How to exclude files from \"git diff\"","fromName":"Nguyen Thai Ngoc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2010-01-05T18:31:24Z","receivedAt":"2010-01-05T18:31:24Z","isPatch":false,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"On 1/6/10, H.J. Lu <hjl.tools@gmail.com> wrote:\n> On Tue, Jan 5, 2010 at 9:54 AM, Dmitry Potapov <dpotapov@gmail.com> wrote:\n>  > On Tue, Jan 5, 2010 at 5:20 PM, H.J. Lu <hjl.tools@gmail.com> wrote:\n>  >>\n>  >> Yes, I want those files in repository. They are for my personal use only.\n>  >\n>  > If you modified some file locally and do not want to see and commit\n>  > those modifications, you may want to use:\n>  >\n>  > git update-index --assume-unchanged foo\n>  >\n>\n>\n> I added those files into my repository for bookkeeping purpose. It\n>  shouldn't go out at all.\n\nThat could be a way to simulate git diff --exclude=\"foo*.bar*\":\n\ngit ls-files -- 'foo*bar*'|xargs git update-index --assume-unchanged\ngit diff\ngit ls-files -- 'foo*bar*'|xargs git update-index --no-assume-unchanged\n\nassume that you don't use assume-unchanged for any other purposes\n-- \nDuy\n"},{"id":"130855","messageId":"7vvdfgxum8.fsf@alter.siamese.dyndns.org","threadId":"21984","inReplyTo":"6dc9ffc81001051015x3bebc994r3d475bdb59e12d39@mail.gmail.com","subject":"Re: How to exclude files from \"git diff\"","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2010-01-05T18:41:03Z","receivedAt":"2010-01-05T18:41:03Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"H.J. Lu\" <hjl.tools@gmail.com> writes:\n\n> On Tue, Jan 5, 2010 at 9:54 AM, Dmitry Potapov <dpotapov@gmail.com> wrote:\n>> On Tue, Jan 5, 2010 at 5:20 PM, H.J. Lu <hjl.tools@gmail.com> wrote:\n>>>\n>>> Yes, I want those files in repository. They are for my personal use only.\n>>\n>> If you modified some file locally and do not want to see and commit\n>> those modifications, you may want to use:\n>>\n>> git update-index --assume-unchanged foo\n>>\n>\n> I added those files into my repository for bookkeeping purpose. It\n> shouldn't go out at all.\n\nSounds like time to run \"rm --cached\" to me.  IOW, keep it untracked.\n"}]}