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

Re: Automatically Add .gitignore Files

From
TThangalin <thangalin@gmail.com>
Date
Feb 9, 2017, 17:25 UTC
Message-ID
<CAANrE7rXUCjBkgmGjiXMMJuTh+FXmw-bLKqonQ4BQP0_=p5m-Q@mail.gmail.com>
In-Reply-To
<CACsJy8DoXCNzryQusEcXtOgeU2ZH1FMGEK32z5b=PGkfvJ0BTg@mail.gmail.com>
Hi Duy,
> This is a general problem to new files, not .gitignore alone. Can we

The difference, to me, is that a ".gitignore" file is not part of what I'm developing. It's an artifact for git configuration. While a .gitignore file is not always pushed to the repository, I imagine that in most situations, it is.

Whereas when a "new" file is created, there are plenty of situations where it shouldn't be added and thus a warning would be superfluous, or an automatic add would be undesirable.

To solve the problem, generally, for new files while giving the user the ability to specify exactly what "new" files should be automatically added to the repository, something like the following would work:

echo "**/.gitignore" >> .git/config/add-before-commit
> and perhaps you want to make it a habit to run it before committing.

Right, because software shouldn't automate repetitive tasks and humans are never prone to forget? ;-)

Previous: Duy Nguyen
Message 5 of 5 in “Automatically Add .gitignore Files”
  1. ThangalinFeb 8, 2017
  2. Junio C HamanoFeb 8, 2017
  3. Stephan BeyerFeb 9, 2017
  4. Duy NguyenFeb 9, 2017
  5. ThangalinFeb 9, 2017

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.