Why does git track directory listed in .gitignore/".git/info/exclude"?

6 messages, 4 authors, 2016-06-15 · open the first message on its own page

Why does git track directory listed in .gitignore/".git/info/exclude"?

From: pradeep singh rautela <hidden>
Date: 2016-06-15 22:44:07

Hi All,

I have an source directory, which in turn has some other directories too.
I do not want to track one of these directories.
So i added the directory name in .gitignore as well as in
.git/info/exclude for my repo.

i.e i have added following line to both of them -
xen-3.1.0-src/

I copied xen-3.1.0-src from archives in the git repo's base directory.

Now when i do a git-status i get
# On branch master
# Untracked files:
#   (use "git add <file>..." to include in what will be committed)
#
#       xen-3.1.0-src/
nothing added to commit but untracked files present (use "git add" to track)

Why is git seeing xen-3.1.0-src directory at all?
Is this the expected behaviour?

I thought i should not get this message after adding relevant entries
in .gitignore or in info/exclude .

What am i doing wrong here?
Is there a way that this can be done without having to witness this
message everytime i do a git status?

Please CC me as I am not subscribed to the list.

Thanks,
         ~Pradeep
-- 
--
pradeep singh rautela
http://eagain.wordpress.com
http://emptydomain.googlepages.com

Re: Why does git track directory listed in .gitignore/".git/info/exclude"?

From: pradeep singh rautela <hidden>
Date: 2016-06-15 22:44:07

Apologies to all.Kindly pardon my novice experiments with git.
Some more trial and error method led to find that you have to put a *
at the end of the directory too.
i.e xen-3.1.0-src/*

But i still would like to ask git gurus here.
Isn't it fine to include a directory name as

   $directory_name/
    instead of
   $directory_name/*

?
Thoughts?

Thanks,
          --Pradeep
On 23/01/2008, pradeep singh rautela [off-list ref] wrote:
Hi All,

I have an source directory, which in turn has some other directories too.
I do not want to track one of these directories.
So i added the directory name in .gitignore as well as in
.git/info/exclude for my repo.

i.e i have added following line to both of them -
xen-3.1.0-src/

I copied xen-3.1.0-src from archives in the git repo's base directory.

Now when i do a git-status i get
# On branch master
# Untracked files:
#   (use "git add <file>..." to include in what will be committed)
#
#       xen-3.1.0-src/
nothing added to commit but untracked files present (use "git add" to track)

Why is git seeing xen-3.1.0-src directory at all?
Is this the expected behaviour?

I thought i should not get this message after adding relevant entries
in .gitignore or in info/exclude .

What am i doing wrong here?
Is there a way that this can be done without having to witness this
message everytime i do a git status?

Please CC me as I am not subscribed to the list.

Thanks,
         ~Pradeep
--
--
pradeep singh rautela
http://eagain.wordpress.com
http://emptydomain.googlepages.com

-- 
--
pradeep singh rautela
http://eagain.wordpress.com
http://emptydomain.googlepages.com

Re: Why does git track directory listed in .gitignore/".git/info/exclude"?

From: Wayne Davison <hidden>
Date: 2016-06-15 22:44:07

On Wed, Jan 23, 2008 at 07:24:44PM +0530, pradeep singh rautela wrote:
i.e i have added following line to both of them -
xen-3.1.0-src/
That doesn't match the directory due to the trailing slash.  If you
remove that slash, it will match the dir, and then ignore anything
you place inside.

..wayne..

Re: Why does git track directory listed in .gitignore/".git/info/exclude"?

From: Linus Torvalds <torvalds@linux-foundation.org>
Date: 2016-06-15 22:44:07


On Wed, 23 Jan 2008, pradeep singh rautela wrote:
Apologies to all.Kindly pardon my novice experiments with git.
Some more trial and error method led to find that you have to put a *
at the end of the directory too.

i.e xen-3.1.0-src/*

But i still would like to ask git gurus here.
Isn't it fine to include a directory name as

   $directory_name/
    instead of
   $directory_name/*
Heh.

I think your problem is that "/" itself. By adding it, the exclude 
information does *not* match the directory entry itself (because the 
directory entry itself is called just "xen-3.1.0-src" - note no slash!), 
and since you added it, it also doesn't match any names _under_ that 
directory exactly.

So what you *should* have done is to just tell git to ignore the directory 
named "xen-3.1.0-src", and you'd have been ok.

Using "xen-3.1.0-src/*" works too, but it is heavy-handed and unnecessary.

		Linus

Re: Why does git track directory listed in .gitignore/".git/info/exclude"?

From: pradeep singh rautela <hidden>
Date: 2016-06-15 22:44:08

Hi Linus,

On 24/01/2008, Linus Torvalds [off-list ref] wrote:
[...]
quoted
Isn't it fine to include a directory name as

   $directory_name/
    instead of
   $directory_name/*
Heh.

I think your problem is that "/" itself. By adding it, the exclude
information does *not* match the directory entry itself (because the
directory entry itself is called just "xen-3.1.0-src" - note no slash!),
and since you added it, it also doesn't match any names _under_ that
directory exactly.
Got that.
Thanks a lot for explaining that to me Linus.

Best Regards,
                --Pradeep
So what you *should* have done is to just tell git to ignore the directory
named "xen-3.1.0-src", and you'd have been ok.

Using "xen-3.1.0-src/*" works too, but it is heavy-handed and unnecessary.

                Linus

-- 
--
pradeep singh rautela
http://eagain.wordpress.com
http://emptydomain.googlepages.com

Re: Why does git track directory listed in .gitignore/".git/info/exclude"?

From: Adam Piatyszek <hidden>
Date: 2016-06-15 22:44:09

* Linus Torvalds [23 I 2008 22:17]:
On Wed, 23 Jan 2008, pradeep singh rautela wrote:
quoted
But i still would like to ask git gurus here.
Isn't it fine to include a directory name as

   $directory_name/
    instead of
   $directory_name/*
Heh.

I think your problem is that "/" itself. By adding it, the exclude 
information does *not* match the directory entry itself (because the 
directory entry itself is called just "xen-3.1.0-src" - note no slash!), 
and since you added it, it also doesn't match any names _under_ that 
directory exactly.

So what you *should* have done is to just tell git to ignore the directory 
named "xen-3.1.0-src", and you'd have been ok.

Using "xen-3.1.0-src/*" works too, but it is heavy-handed and unnecessary.
Hi Linus, Pradeep and All,

In my opinion, the exclude matching routine should convert "dir/" to 
"dir", especially that the "git status" command lists untracked 
directories with the trailing slash "/", e.g:

   ediap@lespaul ~/git/acm_ofdm $ git status
   # On branch master
   # Untracked files:
   #   (use "git add <file>..." to include in what will be committed)
   #
   #       ldpc13.bm
   #       results/

So, most newbies will try to add "dir/" to .gitignore or 
.git/info/exclude instead of "dir" in such a case.

Can you seen any drawbacks of such modification?

BR,
/Adam

-- 
.:.  Adam Piatyszek (ediap)  .:.....................................:.
.:.  ediap@users.sourceforge.net  .:................................:.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help