git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* How to exclude files from "git diff"
@ 2009-12-18 17:09 H.J. Lu
  2010-01-05  6:45 ` Jeff King
  0 siblings, 1 reply; 7+ messages in thread
From: H.J. Lu @ 2009-12-18 17:09 UTC (permalink / raw)
  To: git

Hi,

I have some bookkeeping files in my git repository.  How do I
exclude them from "git diff"? Does "git diff" support

# git diff --exclude="foo.*.bar*"

Please CC me since I am not on the git mailing list.

Thanks.


-- 
H.J.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: How to exclude files from "git diff"
  2009-12-18 17:09 How to exclude files from "git diff" H.J. Lu
@ 2010-01-05  6:45 ` Jeff King
  2010-01-05 14:20   ` H.J. Lu
  0 siblings, 1 reply; 7+ messages in thread
From: Jeff King @ 2010-01-05  6:45 UTC (permalink / raw)
  To: H.J. Lu; +Cc: git

On Fri, Dec 18, 2009 at 09:09:15AM -0800, H.J. Lu wrote:

> I have some bookkeeping files in my git repository.  How do I
> exclude them from "git diff"? Does "git diff" support
> 
> # git diff --exclude="foo.*.bar*"

No, I don't believe there is a way to do that. You would have to do
something like:

  git diff $(git ls-files | grep -v whatever)

The usual concept of "exclusion" for git is not to track files at all
via the .gitignore mechanism.  Are these files that have content you
really _want_ in the repository, but you just don't want to see them
when doing some diffs? Or are they files that could not be in the
repository at all?

-Peff

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: How to exclude files from "git diff"
  2010-01-05  6:45 ` Jeff King
@ 2010-01-05 14:20   ` H.J. Lu
  2010-01-05 17:54     ` Dmitry Potapov
  0 siblings, 1 reply; 7+ messages in thread
From: H.J. Lu @ 2010-01-05 14:20 UTC (permalink / raw)
  To: Jeff King; +Cc: git

On Mon, Jan 4, 2010 at 10:45 PM, Jeff King <peff@peff.net> wrote:
> On Fri, Dec 18, 2009 at 09:09:15AM -0800, H.J. Lu wrote:
>
>> I have some bookkeeping files in my git repository.  How do I
>> exclude them from "git diff"? Does "git diff" support
>>
>> # git diff --exclude="foo.*.bar*"
>
> No, I don't believe there is a way to do that. You would have to do
> something like:
>
>  git diff $(git ls-files | grep -v whatever)
>
> The usual concept of "exclusion" for git is not to track files at all
> via the .gitignore mechanism.  Are these files that have content you
> really _want_ in the repository, but you just don't want to see them
> when doing some diffs? Or are they files that could not be in the
> repository at all?

Yes, I want those files in repository. They are for my personal use only.

Thanks.

-- 
H.J.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: How to exclude files from "git diff"
  2010-01-05 14:20   ` H.J. Lu
@ 2010-01-05 17:54     ` Dmitry Potapov
  2010-01-05 18:15       ` H.J. Lu
  0 siblings, 1 reply; 7+ messages in thread
From: Dmitry Potapov @ 2010-01-05 17:54 UTC (permalink / raw)
  To: H.J. Lu; +Cc: Jeff King, git

On Tue, Jan 5, 2010 at 5:20 PM, H.J. Lu <hjl.tools@gmail.com> wrote:
>
> Yes, I want those files in repository. They are for my personal use only.

If you modified some file locally and do not want to see and commit
those modifications, you may want to use:

git update-index --assume-unchanged foo

After that, git will not notice any change to `foo'. So, 'git diff' and any
other command (such git commit -a) will ignore those changes.

Warning: using  --assume-unchanged may result in losing your changes
if you switch between branches containing different versions of 'foo'.

Normally, when you try to do that, git will not allow switch to another
branch saying that `foo' is modified. But using --assume-unchanged
disables this check. But if you have the same `foo' on all branches
then switching between branches will preserve your modifications.


Dmitry

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: How to exclude files from "git diff"
  2010-01-05 17:54     ` Dmitry Potapov
@ 2010-01-05 18:15       ` H.J. Lu
  2010-01-05 18:31         ` Nguyen Thai Ngoc Duy
  2010-01-05 18:41         ` Junio C Hamano
  0 siblings, 2 replies; 7+ messages in thread
From: H.J. Lu @ 2010-01-05 18:15 UTC (permalink / raw)
  To: Dmitry Potapov; +Cc: Jeff King, git

On Tue, Jan 5, 2010 at 9:54 AM, Dmitry Potapov <dpotapov@gmail.com> wrote:
> On Tue, Jan 5, 2010 at 5:20 PM, H.J. Lu <hjl.tools@gmail.com> wrote:
>>
>> Yes, I want those files in repository. They are for my personal use only.
>
> If you modified some file locally and do not want to see and commit
> those modifications, you may want to use:
>
> git update-index --assume-unchanged foo
>

I added those files into my repository for bookkeeping purpose. It
shouldn't go out at all.


-- 
H.J.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: How to exclude files from "git diff"
  2010-01-05 18:15       ` H.J. Lu
@ 2010-01-05 18:31         ` Nguyen Thai Ngoc Duy
  2010-01-05 18:41         ` Junio C Hamano
  1 sibling, 0 replies; 7+ messages in thread
From: Nguyen Thai Ngoc Duy @ 2010-01-05 18:31 UTC (permalink / raw)
  To: H.J. Lu; +Cc: Dmitry Potapov, Jeff King, git

On 1/6/10, H.J. Lu <hjl.tools@gmail.com> wrote:
> On Tue, Jan 5, 2010 at 9:54 AM, Dmitry Potapov <dpotapov@gmail.com> wrote:
>  > On Tue, Jan 5, 2010 at 5:20 PM, H.J. Lu <hjl.tools@gmail.com> wrote:
>  >>
>  >> Yes, I want those files in repository. They are for my personal use only.
>  >
>  > If you modified some file locally and do not want to see and commit
>  > those modifications, you may want to use:
>  >
>  > git update-index --assume-unchanged foo
>  >
>
>
> I added those files into my repository for bookkeeping purpose. It
>  shouldn't go out at all.

That could be a way to simulate git diff --exclude="foo*.bar*":

git ls-files -- 'foo*bar*'|xargs git update-index --assume-unchanged
git diff
git ls-files -- 'foo*bar*'|xargs git update-index --no-assume-unchanged

assume that you don't use assume-unchanged for any other purposes
-- 
Duy

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: How to exclude files from "git diff"
  2010-01-05 18:15       ` H.J. Lu
  2010-01-05 18:31         ` Nguyen Thai Ngoc Duy
@ 2010-01-05 18:41         ` Junio C Hamano
  1 sibling, 0 replies; 7+ messages in thread
From: Junio C Hamano @ 2010-01-05 18:41 UTC (permalink / raw)
  To: H.J. Lu; +Cc: Dmitry Potapov, Jeff King, git

"H.J. Lu" <hjl.tools@gmail.com> writes:

> On Tue, Jan 5, 2010 at 9:54 AM, Dmitry Potapov <dpotapov@gmail.com> wrote:
>> On Tue, Jan 5, 2010 at 5:20 PM, H.J. Lu <hjl.tools@gmail.com> wrote:
>>>
>>> Yes, I want those files in repository. They are for my personal use only.
>>
>> If you modified some file locally and do not want to see and commit
>> those modifications, you may want to use:
>>
>> git update-index --assume-unchanged foo
>>
>
> I added those files into my repository for bookkeeping purpose. It
> shouldn't go out at all.

Sounds like time to run "rm --cached" to me.  IOW, keep it untracked.

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2010-01-05 18:41 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-12-18 17:09 How to exclude files from "git diff" H.J. Lu
2010-01-05  6:45 ` Jeff King
2010-01-05 14:20   ` H.J. Lu
2010-01-05 17:54     ` Dmitry Potapov
2010-01-05 18:15       ` H.J. Lu
2010-01-05 18:31         ` Nguyen Thai Ngoc Duy
2010-01-05 18:41         ` Junio C Hamano

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).