git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
APAdam Piatyszek <ediap@users.sourceforge.net>
Date
Jan 30, 2008, 12:35 UTC
Message-ID
<47A06EF9.60704@users.sourceforge.net>
In-Reply-To
<alpine.LFD.1.00.0801231313590.2803@woody.linux-foundation.org>
* Linus Torvalds [23 I 2008 22:17]:
Show 20 quoted lines
> On Wed, 23 Jan 2008, pradeep singh rautela wrote:
>> 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  .:................................:.
Previous: pradeep singh rautelaNext: Junio C Hamano
Message 5 of 20 in “Why does git track directory listed in .gitignore/".git/info/exclude"?”
  1. pradeep singh rautelaJan 23, 2008
  2. pradeep singh rautelaJan 23, 2008
  3. Linus TorvaldsJan 23, 2008
  4. pradeep singh rautelaJan 24, 2008
  5. Adam PiatyszekJan 30, 2008
  6. Junio C HamanoJan 30, 2008
  7. Junio C HamanoJan 30, 2008
  8. Adam PiatyszekJan 31, 2008
  9. *Re: Why does git track directory listed in .gitignore/".git/info/exclude"?Junio C Hamano, Jan 31, 2008
  10. gitignore(5): Allow "foo/" in ignore list to match directory "foo"Junio C Hamano, Jan 31, 2008
  11. Jeff KingJan 31, 2008
  12. Junio C HamanoJan 31, 2008
  13. Jeff KingJan 31, 2008
  14. Johannes SchindelinJan 31, 2008
  15. pradeep singh rautelaJan 31, 2008
  16. Junio C HamanoJan 31, 2008
  17. Adam PiatyszekJan 31, 2008
  18. Andreas EricssonFeb 1, 2008
  19. Adam PiatyszekJan 31, 2008
  20. Wayne DavisonJan 23, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.