Subject: Gitignore matching "git add" wildcard prevents operation

From: Marko Poutiainen <[email-masked]>
Date: Thu, 14 Jan 2010 20:18:40 +0200

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")