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

Automatically Add .gitignore Files

From
TThangalin <thangalin@gmail.com>
Date
Feb 8, 2017, 19:05 UTC
Message-ID
<CAANrE7rmUZcJkw+thMczv3D=7sqcUHBsorzvEZgYg=6AEfrU=w@mail.gmail.com>
I frequently forget to add .gitignore files when creating new .gitignore files.

I'd like to request a command-line option to always add .gitignore files (or, more generally, always add files that match a given file specification).

Replicate
0. git init ...
1. echo "*.bak" >> .gitignore
2. touch file.txt
3. git add file.txt
4. git commit -a -m "..."
5. git push origin master
Expected Results

The .gitignore file is also added to the repository. (This is probably the 80% use case.)

Actual Results
The .gitignore file is not added to the repository.
Additional Details

At step 4, there should be a prompt, warning, or (preferably) either a command-line or configuration option to add the .gitignore file prior to commit, automatically. Such as:

git commit --include-all-gitignore-files -a -m "..."
Or:
echo "**/.gitignore" >> .git/config/add-before-commit
Next: Junio C Hamano
Message 1 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.