Hey all,
I’ve run into a strange behavior of git-add that I believe is not correct. I couldn’t find something on the mailing list regarding this, so I am writing a new mail. The issue is that if you use git-add with an explicit pathspec with an exclude pattern of a file that is ignored by some .gitignore file (locally or globally) the git-add command errors with the following message:
git add --":(exclude)ignored.txt"
The following paths are ignored by one of your ".gitignore" files:
ignored.txt
Note: Use -f if you really want to add them.
Note: Disable this message with "git config set advice.addIgnoredFile false"
Steps to reproduce:
mkdir git-add-test
cd git-add-test
git init
touch .gitignore
echo “ignored.txt” >>.gitignore
touch ignored.txt
git add --“:(exclude)ignored.txt”
Expected behavior:
The git add command recognizes that the file ignored.txt is already excluded despite of it being ignored by some gitignore and thus does not check if it is ignored or not. It simply will not be added.
Note forcing git-add will do the trick, but this could also have side effects for some files that are ignored but not present in the list of excluded files.
Hence, this can’t be the right solution.
Any advice or confirmation are much appreciated.
Thank you
René Rahn