git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* ignoring files/directories in git
@ 2008-09-21 16:54 mwolfe38
  2008-09-21 17:19 ` Boaz Harrosh
                   ` (4 more replies)
  0 siblings, 5 replies; 12+ messages in thread
From: mwolfe38 @ 2008-09-21 16:54 UTC (permalink / raw)
  To: git


I'm working on a project by myself and using git mostly just to learn about
it.
In my project I have several directories I do not want to have git ignore.
One of them being
cache/ and the other log/
I've added them to the .gitignore file which I have in the initial directory
of the repository
The contents of my gitignore are:

.settings
.cache
cache/
log/
.project

However, if I do 
git add .
It will add the files from cache and log anyways.
I know git add . will add anything that hasn't been added but shouldn't it
ignore files in .gitignore?
If not, what is the point, I would just ignore them manually anyways. 
The main reason i like doing git add .
is because i'm using symfony php framework which makes good use of scripts
which generates lots if initial files for you and thus adding one at a time
would be a pain.

Any idea what might be going on here?  I thought maybe I had added those
directories before putting them in .gitignore so i used git rm -r to remove
them but they still show back up with doing git add .

Thanks in advance
-- 
View this message in context: http://www.nabble.com/ignoring-files-directories-in-git-tp19596152p19596152.html
Sent from the git mailing list archive at Nabble.com.

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

* Re: ignoring files/directories in git
  2008-09-21 16:54 ignoring files/directories in git mwolfe38
@ 2008-09-21 17:19 ` Boaz Harrosh
  2008-09-21 17:20 ` Alex Riesen
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 12+ messages in thread
From: Boaz Harrosh @ 2008-09-21 17:19 UTC (permalink / raw)
  To: mwolfe38; +Cc: git

mwolfe38 wrote:
> I'm working on a project by myself and using git mostly just to learn about
> it.
> In my project I have several directories I want to have git ignore. One of
> them being
> cache/ and the other log/
> I've added them to the .gitignore file which I have in the initial directory
> of the repository
> The contents of my gitignore are:
> 
> .settings
> .cache
> cache/
> log/

If I use "patches/" in my .gitignore file and then git-status 
then I get all these extra files in the "Untracked files:" section
but if I use plain "patches" (No slash at end) then it works. Sounds
like a bug to me but it sure is a workaround.

> .project
> 
> However, if I do 
> git add .
> It will add the files from cache and log anyways.
> I know git add . will add anything that hasn't been added but shouldn't it
> ignore files in .gitignore?
> If not, what is the point, I would just ignore them manually anyways. 
> The main reason i like doing git add .
> is because i'm using symfony php framework which makes good use of scripts
> which generates lots if initial files for you and thus adding one at a time
> would be a pain.
> 
> Any idea what might be going on here?  I thought maybe I had added those
> directories before putting them in .gitignore so i used git rm -r to remove
> them but they still show back up with doing git add .
> 
> Thanks in advance

Boaz

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

* Re: ignoring files/directories in git
  2008-09-21 16:54 ignoring files/directories in git mwolfe38
  2008-09-21 17:19 ` Boaz Harrosh
@ 2008-09-21 17:20 ` Alex Riesen
  2008-09-21 17:42 ` mwolfe38
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 12+ messages in thread
From: Alex Riesen @ 2008-09-21 17:20 UTC (permalink / raw)
  To: mwolfe38; +Cc: git

mwolfe38, Sun, Sep 21, 2008 18:54:01 +0200:
> In my project I have several directories I do not want to have git ignore.
> One of them being
> cache/ and the other log/
> I've added them to the .gitignore file which I have in the initial directory
> of the repository
> The contents of my gitignore are:
> 
> .settings
> .cache
> cache/
> log/
> .project
> 
> However, if I do 
> git add .
> It will add the files from cache and log anyways.
> I know git add . will add anything that hasn't been added but shouldn't it
> ignore files in .gitignore?

It should and indeed it does ignore them:

    $ mkdir ggg && cd ggg
    $ git init
    Initialized empty Git repository in /tmp/ggg/.git/
    $ >a
    $ mkdir cache log
    $ touch cache/b
    $ touch log/c
    $ echo cache/ >.gitignore
    $ echo log/ >>.gitignore
    $ cat .gitignore
    cache
    log
    $ git add .
    $ git ls-files
    .gitignore
    a

What is your git version and where have you got it from?
Is your .gitignore written exactly like this (case, some hidden
extension, like they do on Windows)? Any invisible characters in
.gitignore?

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

* Re: ignoring files/directories in git
  2008-09-21 16:54 ignoring files/directories in git mwolfe38
  2008-09-21 17:19 ` Boaz Harrosh
  2008-09-21 17:20 ` Alex Riesen
@ 2008-09-21 17:42 ` mwolfe38
  2008-09-22 18:47   ` Tim Harper
  2008-09-21 17:42 ` Dmitry Potapov
  2008-09-22  0:06 ` mwolfe38
  4 siblings, 1 reply; 12+ messages in thread
From: mwolfe38 @ 2008-09-21 17:42 UTC (permalink / raw)
  To: git


Fixed, by removing the trailing / in the names it will then ignore all files
in that directory,
so now i just have
cache 
log
instead of 
cache/ and log/




mwolfe38 wrote:
> 
> I'm working on a project by myself and using git mostly just to learn
> about it.
> In my project I have several directories I want to have git ignore. One of
> them being
> cache/ and the other log/
> I've added them to the .gitignore file which I have in the initial
> directory of the repository
> The contents of my gitignore are:
> 
> .settings
> .cache
> cache/
> log/
> .project
> 
> However, if I do 
> git add .
> It will add the files from cache and log anyways.
> I know git add . will add anything that hasn't been added but shouldn't it
> ignore files in .gitignore?
> If not, what is the point, I would just ignore them manually anyways. 
> The main reason i like doing git add .
> is because i'm using symfony php framework which makes good use of scripts
> which generates lots if initial files for you and thus adding one at a
> time would be a pain.
> 
> Any idea what might be going on here?  I thought maybe I had added those
> directories before putting them in .gitignore so i used git rm -r to
> remove them but they still show back up with doing git add .
> 
> Thanks in advance
> 

-- 
View this message in context: http://www.nabble.com/ignoring-files-directories-in-git-tp19596152p19596620.html
Sent from the git mailing list archive at Nabble.com.

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

* Re: ignoring files/directories in git
  2008-09-21 16:54 ignoring files/directories in git mwolfe38
                   ` (2 preceding siblings ...)
  2008-09-21 17:42 ` mwolfe38
@ 2008-09-21 17:42 ` Dmitry Potapov
  2008-09-22  0:06 ` mwolfe38
  4 siblings, 0 replies; 12+ messages in thread
From: Dmitry Potapov @ 2008-09-21 17:42 UTC (permalink / raw)
  To: mwolfe38; +Cc: git

On Sun, Sep 21, 2008 at 09:54:38AM -0700, mwolfe38 wrote:
> 
> I've added them to the .gitignore file which I have in the initial directory
> of the repository
> The contents of my gitignore are:
> 
> .settings
> .cache
> cache/
> log/
> .project
> 
> However, if I do 
> git add .
> It will add the files from cache and log anyways.
> I know git add . will add anything that hasn't been added but shouldn't it
> ignore files in .gitignore?

It does ignore files in .gitignore. What version of Git do you use?
IIRC, some old ones did not like the slash at the end of name.

Dmitry

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

* Re: ignoring files/directories in git
  2008-09-21 16:54 ignoring files/directories in git mwolfe38
                   ` (3 preceding siblings ...)
  2008-09-21 17:42 ` Dmitry Potapov
@ 2008-09-22  0:06 ` mwolfe38
  2008-09-22  7:37   ` Boaz Harrosh
  4 siblings, 1 reply; 12+ messages in thread
From: mwolfe38 @ 2008-09-22  0:06 UTC (permalink / raw)
  To: git


I just thought that I would add that the reason is a bug in the 1.5.4.3
version that I am using which is the ubuntu 8.04 repository version.
According to some developers, the current version should fix this issue.


mwolfe38 wrote:
> 
> I'm working on a project by myself and using git mostly just to learn
> about it.
> In my project I have several directories I want to have git ignore. One of
> them being
> cache/ and the other log/
> I've added them to the .gitignore file which I have in the initial
> directory of the repository
> The contents of my gitignore are:
> 
> .settings
> .cache
> cache/
> log/
> .project
> 
> However, if I do 
> git add .
> It will add the files from cache and log anyways.
> I know git add . will add anything that hasn't been added but shouldn't it
> ignore files in .gitignore?
> If not, what is the point, I would just ignore them manually anyways. 
> The main reason i like doing git add .
> is because i'm using symfony php framework which makes good use of scripts
> which generates lots if initial files for you and thus adding one at a
> time would be a pain.
> 
> Any idea what might be going on here?  I thought maybe I had added those
> directories before putting them in .gitignore so i used git rm -r to
> remove them but they still show back up with doing git add .
> 
> Thanks in advance
> 

-- 
View this message in context: http://www.nabble.com/ignoring-files-directories-in-git-tp19596152p19599905.html
Sent from the git mailing list archive at Nabble.com.

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

* Re: ignoring files/directories in git
  2008-09-22  0:06 ` mwolfe38
@ 2008-09-22  7:37   ` Boaz Harrosh
  2008-09-22  8:52     ` Dmitry Potapov
  0 siblings, 1 reply; 12+ messages in thread
From: Boaz Harrosh @ 2008-09-22  7:37 UTC (permalink / raw)
  To: mwolfe38; +Cc: git

mwolfe38 wrote:
> I just thought that I would add that the reason is a bug in the 1.5.4.3
> version that I am using which is the ubuntu 8.04 repository version.
> According to some developers, the current version should fix this issue.
> 
> 
[Please don't top-post]

I have 1.6.0.1 I compiled here, and it has the same problem. So it is
a very recent fix

> mwolfe38 wrote:
>> I'm working on a project by myself and using git mostly just to learn
>> about it.
>> In my project I have several directories I want to have git ignore. One of
>> them being
>> cache/ and the other log/
>> I've added them to the .gitignore file which I have in the initial
>> directory of the repository
>> The contents of my gitignore are:
>>
>> .settings
>> .cache
>> cache/
>> log/
>> .project
>>
>> However, if I do 
>> git add .
>> It will add the files from cache and log anyways.
>> I know git add . will add anything that hasn't been added but shouldn't it
>> ignore files in .gitignore?
>> If not, what is the point, I would just ignore them manually anyways. 
>> The main reason i like doing git add .
>> is because i'm using symfony php framework which makes good use of scripts
>> which generates lots if initial files for you and thus adding one at a
>> time would be a pain.
>>
>> Any idea what might be going on here?  I thought maybe I had added those
>> directories before putting them in .gitignore so i used git rm -r to
>> remove them but they still show back up with doing git add .
>>
>> Thanks in advance
>>
> 

Boaz

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

* Re: ignoring files/directories in git
  2008-09-22  7:37   ` Boaz Harrosh
@ 2008-09-22  8:52     ` Dmitry Potapov
  2008-09-22 10:41       ` Boaz Harrosh
  0 siblings, 1 reply; 12+ messages in thread
From: Dmitry Potapov @ 2008-09-22  8:52 UTC (permalink / raw)
  To: Boaz Harrosh; +Cc: mwolfe38, git

On Mon, Sep 22, 2008 at 10:37:00AM +0300, Boaz Harrosh wrote:
> 
> I have 1.6.0.1 I compiled here, and it has the same problem. So it is
> a very recent fix

I certainly tested 1.6.0.1 and does not have this problem, and it was
fixed a long time ago:

===
commit d6b8fc303b389b026f2bf9918f6f83041488989b
Author: Junio C Hamano <gitster@pobox.com>
Date:   Thu Jan 31 01:17:48 2008 -0800

    gitignore(5): Allow "foo/" in ignore list to match directory "foo"

    A pattern "foo/" in the exclude list did not match directory
    "foo", but a pattern "foo" did.  This attempts to extend the
    exclude mechanism so that it would while not matching a regular
    file or a symbolic link "foo".  In order to differentiate a
    directory and non directory, this passes down the type of path
    being checked to excluded() function.

    A downside is that the recursive directory walk may need to run
    lstat(2) more often on systems whose "struct dirent" do not give
    the type of the entry; earlier it did not have to do so for an
    excluded path, but we now need to figure out if a path is a
    directory before deciding to exclude it.  This is especially bad
    because an idea similar to the earlier CE_UPTODATE optimization
    to reduce number of lstat(2) calls would by definition not apply
    to the codepaths involved, as (1) directories will not be
    registered in the index, and (2) excluded paths will not be in
    the index anyway.
===

The patch is included in 1.5.5.

Dmitry

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

* Re: ignoring files/directories in git
  2008-09-22  8:52     ` Dmitry Potapov
@ 2008-09-22 10:41       ` Boaz Harrosh
  2008-09-22 11:53         ` Andreas Ericsson
  2008-09-22 12:19         ` Dmitry Potapov
  0 siblings, 2 replies; 12+ messages in thread
From: Boaz Harrosh @ 2008-09-22 10:41 UTC (permalink / raw)
  To: Dmitry Potapov; +Cc: mwolfe38, git

Dmitry Potapov wrote:
> On Mon, Sep 22, 2008 at 10:37:00AM +0300, Boaz Harrosh wrote:
>> I have 1.6.0.1 I compiled here, and it has the same problem. So it is
>> a very recent fix
> 
> I certainly tested 1.6.0.1 and does not have this problem, and it was
> fixed a long time ago:
> 
> ===
> commit d6b8fc303b389b026f2bf9918f6f83041488989b
> Author: Junio C Hamano <gitster@pobox.com>
> Date:   Thu Jan 31 01:17:48 2008 -0800
> 
>     gitignore(5): Allow "foo/" in ignore list to match directory "foo"
> 
>     A pattern "foo/" in the exclude list did not match directory
>     "foo", but a pattern "foo" did.  This attempts to extend the
>     exclude mechanism so that it would while not matching a regular
>     file or a symbolic link "foo".  In order to differentiate a
>     directory and non directory, this passes down the type of path
>     being checked to excluded() function.
> 
>     A downside is that the recursive directory walk may need to run
>     lstat(2) more often on systems whose "struct dirent" do not give
>     the type of the entry; earlier it did not have to do so for an
>     excluded path, but we now need to figure out if a path is a
>     directory before deciding to exclude it.  This is especially bad
>     because an idea similar to the earlier CE_UPTODATE optimization
>     to reduce number of lstat(2) calls would by definition not apply
>     to the codepaths involved, as (1) directories will not be
>     registered in the index, and (2) excluded paths will not be in
>     the index anyway.
> ===
> 
> The patch is included in 1.5.5.
> 
> Dmitry
> --

Ok I found it. Regular subdirectories it works as you said,
but soft-link to a folder does not. Sorry for the noise i didn't
realize that in my test it was a simlink and not a full directory.

Please don't fix it if it will hurt performance, I'm happy with
current solution as it is. Just maybe a small addition to the
.gitignore documentation perhaps.

Boaz

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

* Re: ignoring files/directories in git
  2008-09-22 10:41       ` Boaz Harrosh
@ 2008-09-22 11:53         ` Andreas Ericsson
  2008-09-22 12:19         ` Dmitry Potapov
  1 sibling, 0 replies; 12+ messages in thread
From: Andreas Ericsson @ 2008-09-22 11:53 UTC (permalink / raw)
  To: Boaz Harrosh; +Cc: Dmitry Potapov, mwolfe38, git

Boaz Harrosh wrote:
> Dmitry Potapov wrote:
>> On Mon, Sep 22, 2008 at 10:37:00AM +0300, Boaz Harrosh wrote:
>>> I have 1.6.0.1 I compiled here, and it has the same problem. So it is
>>> a very recent fix
>> I certainly tested 1.6.0.1 and does not have this problem, and it was
>> fixed a long time ago:
>>
>> ===
>> commit d6b8fc303b389b026f2bf9918f6f83041488989b
>> Author: Junio C Hamano <gitster@pobox.com>
>> Date:   Thu Jan 31 01:17:48 2008 -0800
>>
>>     gitignore(5): Allow "foo/" in ignore list to match directory "foo"
>>
>>     A pattern "foo/" in the exclude list did not match directory
>>     "foo", but a pattern "foo" did.  This attempts to extend the
>>     exclude mechanism so that it would while not matching a regular
>>     file or a symbolic link "foo".  In order to differentiate a
>>     directory and non directory, this passes down the type of path
>>     being checked to excluded() function.
>>
>>     A downside is that the recursive directory walk may need to run
>>     lstat(2) more often on systems whose "struct dirent" do not give
>>     the type of the entry; earlier it did not have to do so for an
>>     excluded path, but we now need to figure out if a path is a
>>     directory before deciding to exclude it.  This is especially bad
>>     because an idea similar to the earlier CE_UPTODATE optimization
>>     to reduce number of lstat(2) calls would by definition not apply
>>     to the codepaths involved, as (1) directories will not be
>>     registered in the index, and (2) excluded paths will not be in
>>     the index anyway.
>> ===
>>
>> The patch is included in 1.5.5.
>>
>> Dmitry
>> --
> 
> Ok I found it. Regular subdirectories it works as you said,
> but soft-link to a folder does not. Sorry for the noise i didn't
> realize that in my test it was a simlink and not a full directory.
> 
> Please don't fix it if it will hurt performance, I'm happy with
> current solution as it is. Just maybe a small addition to the
> .gitignore documentation perhaps.
> 

It wouldn't hurt performance (noticeably) to change the lstat()
call to a stat() call. It's slightly more work for the kernel,
but assuming you don't have tens of thousands of symlinks it
really won't make a difference. I'm not sure what other things
would break from using stat() instead of lstat() in the exclude
matching code though, so it's not so simple as just replacing
it.

-- 
Andreas Ericsson                   andreas.ericsson@op5.se
OP5 AB                             www.op5.se
Tel: +46 8-230225                  Fax: +46 8-230231

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

* Re: ignoring files/directories in git
  2008-09-22 10:41       ` Boaz Harrosh
  2008-09-22 11:53         ` Andreas Ericsson
@ 2008-09-22 12:19         ` Dmitry Potapov
  1 sibling, 0 replies; 12+ messages in thread
From: Dmitry Potapov @ 2008-09-22 12:19 UTC (permalink / raw)
  To: Boaz Harrosh; +Cc: mwolfe38, git

On Mon, Sep 22, 2008 at 01:41:07PM +0300, Boaz Harrosh wrote:
> 
> Ok I found it. Regular subdirectories it works as you said,
> but soft-link to a folder does not.

Why should it? Git does not follow symbolic links regardless whether
they point to files or directories. In fact, Git does extra checks to
avoid something like: symlink-to-dir/normal-file to be added as a
normal file. There was some discussion about it a couple months ago
("Not going beyond symbolic links").


Dmitry

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

* Re: ignoring files/directories in git
  2008-09-21 17:42 ` mwolfe38
@ 2008-09-22 18:47   ` Tim Harper
  0 siblings, 0 replies; 12+ messages in thread
From: Tim Harper @ 2008-09-22 18:47 UTC (permalink / raw)
  To: git

On Sep 21, 2008, at 11:42 AM, mwolfe38 wrote:

>
> Fixed, by removing the trailing / in the names it will then ignore  
> all files
> in that directory,
> so now i just have
> cache
> log
> instead of
> cache/ and log/

FYI, you might try this instead:
/cache
/log

It's more specific, and if you had a file like "/lib/adapters/log/ 
rotater.rb", it wouldn't be ignored, whereas it would without the  
leading slashes.

Tim

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

end of thread, other threads:[~2008-09-22 18:48 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-09-21 16:54 ignoring files/directories in git mwolfe38
2008-09-21 17:19 ` Boaz Harrosh
2008-09-21 17:20 ` Alex Riesen
2008-09-21 17:42 ` mwolfe38
2008-09-22 18:47   ` Tim Harper
2008-09-21 17:42 ` Dmitry Potapov
2008-09-22  0:06 ` mwolfe38
2008-09-22  7:37   ` Boaz Harrosh
2008-09-22  8:52     ` Dmitry Potapov
2008-09-22 10:41       ` Boaz Harrosh
2008-09-22 11:53         ` Andreas Ericsson
2008-09-22 12:19         ` Dmitry Potapov

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).