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

Gitignore matching "git add" wildcard prevents operation

From
MPMarko Poutiainen <regs@sofistes.net>
Date
Jan 14, 2010, 18:18 UTC
Message-ID
<4B4F6000.4070005@sofistes.net>

It seems that that there is a bug related to how Git handles the add command with wildcards if the wildcard also matches a file that is ignored.

E.g (I activate the *.[ao] rule when editing .git/info/exclude):

mep@Blackbird:~$ cd /tmp mep@Blackbird:/tmp$ mkdir git mep@Blackbird:/tmp$ cd git mep@Blackbird:/tmp/git$ git init Initialized empty Git repository in /tmp/git/.git/ mep@Blackbird:/tmp/git$ nano -w .git/info/exclude mep@Blackbird:/tmp/git$ touch a.o a.c a.h mep@Blackbird:/tmp/git$ git add a.* The following paths are ignored by one of your .gitignore files: a.o Use -f if you really want to add them. fatal: no files added mep@Blackbird:/tmp/git$ git status # On branch master # # Initial commit # # Untracked files: # (use "git add <file>..." to include in what will be committed) # # a.c # a.h # a.o nothing added to commit but untracked files present (use "git add" to track)

Furthermore:
mep@Blackbird:/tmp/git$ git add .
mep@Blackbird:/tmp/git$ git commit -m "foo"
[master (root-commit) 43da825] foo
 0 files changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 a.c
 create mode 100644 a.h
mep@Blackbird:/tmp/git$ nano a.c
mep@Blackbird:/tmp/git$ nano a.h
mep@Blackbird:/tmp/git$ git add a.*
The following paths are ignored by one of your .gitignore files:
a.o
Use -f if you really want to add them.
fatal: no files added
mep@Blackbird:/tmp/git$ git status
# On branch master
# Changed but not updated:
#   (use "git add <file>..." to update what will be committed)
#   (use "git checkout -- <file>..." to discard changes in working
directory)
#
#       modified:   a.c
#       modified:   a.h
#
no changes added to commit (use "git add" and/or "git commit -a")
Next: Jeff King
Message 1 of 12 in “Gitignore matching "git add" wildcard prevents operation”
  1. Marko PoutiainenJan 14, 2010
  2. Jeff KingJan 14, 2010
  3. Junio C HamanoJan 14, 2010
  4. Jeff KingJan 14, 2010
  5. Nicolas SebrechtJan 15, 2010
  6. Jeff KingJan 15, 2010
  7. Nicolas SebrechtJan 15, 2010
  8. Jeff KingJan 15, 2010
  9. Nicolas SebrechtJan 15, 2010
  10. Junio C HamanoJan 15, 2010
  11. Marko PoutiainenJan 14, 2010
  12. Nicolas SebrechtJan 15, 2010

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.