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

Re: Default exclude rules for Git

From
Junio C Hamano <gitster@pobox.com>
Date
Sep 19, 2008, 15:46 UTC
Message-ID
<7v8wtouoit.fsf@gitster.siamese.dyndns.org>
In-Reply-To
<20080919142211.GE10360@machine.or.cz>
Petr Baudis <pasky@suse.cz> writes:
Show 18 quoted lines
> I think it would actually make most sense to insert some conservative
> default ignore rules to the Git's stock excludes template. (Or better,
> have a single file with default Git's exclude rules. Tools newly
> installed on the system could even add their entries there during
> installation as Git's quest on world dominations progresses.) I'd
> shamelessly propose Cogito's set of default excludes for starters:
>
> 	*.[ao]
> 	.*
> 	!.git*
> 	tags
> 	*~
> 	#*
>
> (or omit the first line if that feels too C-specific - but I think it
> should be extremely rare to find files you _want_ to track even in non-C
> projects; and I'd argue anytime that by default ignoring hidden files
> is absolutely the sanest thing to do.)

I do not see a need to change any canned template shipped with git. I actually think it is a grave regression to add anything arbitrary, even if one person happens to think the choice is conservative, to the set of tool-wide ignore patterns. And here is why.

I haven't personally seen any project that wants its users to _edit_ a file whose names end with ".a" or ".o" and track it. That does not however mean that there can be no project and/or environment that validly wants to track files with ".o" suffix (isn't it the case that windows shop use ".obj" for object files and ".o" suffix do not have any particular meaning to them?) By placing "*.o" to tool-wide ignore file, your version of git is making life for participants in such a project harder because they can now easily forget to add a newly created "*.o" files (status won't show them). The tool should be extremely conservative not to encourage such mistakes.

The best place to express such a project wide policy (e.g. "in this project, '*.o' files will never, or rarely if ever, be tracked and we expect our developers to appreciate not seeing them in status output by default") is a tracked .gitignore file.

I earlier said that "*~" should not be in project-wide .gitignore file because use of Emacs vs vi is a matter of personal taste, and Emacs specific "*~" pattern does not belong to a project policy, just like vim "*.swp" pattern doesn't.

But I think that reasoning is flawed. The right criteria should not be about "use of Emacs vs vi", but about "do we in this project ever want to track files that match *~ or *.swp as legitimate contents". If a project expects not to have a tracked file whose name ends with ".swp", even if it does _not_ mean to encourage use of vim over Emacs or any other editor, I think it is fine to add such to its tracked .gitignore file for its developer's benefit.

Previous: Petr BaudisNext: Petr Baudis
Message 18 of 22 in “A couple of TopGit tweaks”
  1. Kirill SmelkovSep 18, 2008
  2. .gitignore += vim swap filesKirill Smelkov, Sep 18, 2008
  3. martin f krafftSep 18, 2008
  4. Kirill SmelkovSep 18, 2008
  5. Bert WesargSep 18, 2008
  6. Kirill SmelkovSep 18, 2008
  7. Bert WesargSep 18, 2008
  8. Kirill SmelkovSep 18, 2008
  9. martin f krafftSep 18, 2008
  10. Daniel BarkalowSep 18, 2008
  11. Kirill SmelkovSep 19, 2008
  12. Bert WesargSep 19, 2008
  13. Kirill SmelkovSep 19, 2008
  14. Andreas EricssonSep 19, 2008
  15. Kirill SmelkovSep 19, 2008
  16. Bert WesargSep 19, 2008
  17. Default exclude rules for GitPetr Baudis, Sep 19, 2008
  18. Junio C HamanoSep 19, 2008
  19. Petr BaudisSep 19, 2008
  20. Avery PennarunSep 19, 2008
  21. tg help: <something>: improve readabilityKirill Smelkov, Sep 18, 2008
  22. tg import: fix + make more robustKirill Smelkov, Sep 18, 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.