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

Re: /* in .gitignore

From
Junio C Hamano <gitster@pobox.com>
Date
Sep 25, 2012, 23:13 UTC
Message-ID
<7vobktvgq8.fsf@alter.siamese.dyndns.org>
In-Reply-To
<CAE1pOi1vEGVcg5wn9VjkSVmMO_hparmYP0hn86XwpSpMmB=Peg@mail.gmail.com>
Hilco Wijbenga <hilco.wijbenga@gmail.com> writes:
> Naturally, this behaviour makes perfect sense: "/*" means everything.
> Still, I was wondering whether it might be a good idea to make an
> exception for '.gitignore' itself? Then if somebody *really* wanted to
> ignore '.gitignore' they could add "/.gitignore" to '.gitignore'?

If somebody is sick enough to ignore "everything", he can add "/*" to the .gitignore file and in order to make sure he knows what he is doing and he is doing what he thinks is doing, he would check with "git diff --stat HEAD" etc. before committing, and double check with "git show --stat" etc. after committing.

".gitignore" (or ".gitattributes" for that matter) shouldn't be any different from your ordinary tracked contents. If you have "*.o" in the ignored pattern list, you would need an extra care to defeat the pattern to add vendor-supplied binary-only object file with "add -f" and live with the fact that a new vendor-supplied binary-only object file not appearing on untracked list. It is exactly the same deal.

Having said that, I guess you could add "!.git*" to your $GIT_DIR/info/exclude and see if it gives an improved user experience.

Previous: Hilco WijbengaNext: Hilco Wijbenga
Message 2 of 3 in “/* in .gitignore”
  1. Hilco WijbengaSep 25, 2012
  2. Junio C HamanoSep 25, 2012
  3. Hilco WijbengaSep 26, 2012

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.