On Thu, Aug 12, 2010 at 15:54, Greg Brockman [off-list ref] wrote:
Secondly, I don't think this makes '-f' useless. '-f' would still be
used to initially add an untracked file to the index. So this would
maintain an invariant that no ignored files are tracked unless the
user has specified a '-f' for it in the past.
I initially misread what this series was about, and I was about to
withdraw my support for it. But this seems completely reasonable, and
actually I think Git's current behavior here is clearly a bug.
To elabore with examples this behavior here is fine, and I think
everyone agrees with that:
aoeu tmp (160M) $ git init meh
Initialized empty Git repository in /tmp/meh/.git/
aoeu tmp (160M) $ cd !$
cd meh
aoeu meh (master) $ echo '*' > .gitignore
aoeu meh (master) $ mkdir ignore-dir
aoeu meh (master) $ echo ignore > ignore-dir/file
aoeu meh (master) $ echo ignore > file
aoeu meh (master) $ git add file ignore-dir
The following paths are ignored by one of your .gitignore files:
file
ignore-dir
Use -f if you really want to add them.
fatal: no files added
Here I have * in .gitignore but I'm adding files with an explicit
path. Making this not ask for -f would be pretty bad, e.g. for the
glob reasons Junio cited.
So I have to -f it:
aoeu meh (master) $ git add -f file ignore-dir
aoeu meh (master) $ git commit -m"commiting ignored stuff"
[master (root-commit) 6cae514] commiting ignored stuff
2 files changed, 2 insertions(+), 0 deletions(-)
create mode 100644 file
create mode 100644 ignore-dir/file
However this part I think is a bug:
aoeu meh (master) $ echo whee >> ignore-dir/file
aoeu meh (master) $ echo whee >> file
aoeu meh (master) $ git status --short
M file
M ignore-dir/file
aoeu meh (master) $ git add file
aoeu meh (master) $ git add ignore-dir/file
The following paths are ignored by one of your .gitignore files:
ignore-dir
Use -f if you really want to add them.
fatal: no files added
$ git status --short
M file
M ignore-dir/file
Here "file" is already tracked by Git and it doesn't complain when I
"git add" a update to it, but it complains about "ignore-dir/file"
just because it's in a subdirectory.
I hadn't noticed this before because I usually use "git add -u", which
doesn't complain about the ignore and happily updates the file in the
index:
aoeu meh (master) $ git add -u
aoeu meh (master) $ git status --short
M file
M ignore-dir/file
I think "git add ignore-dir/file" above should act exactly like "git
add file", and not force me to add a "-f" to "git add".