git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* git-add ignores exclude markers for ignored files
@ 2025-11-04 15:59 Rahn, René
  2025-11-04 22:11 ` Junio C Hamano
  0 siblings, 1 reply; 3+ messages in thread
From: Rahn, René @ 2025-11-04 15:59 UTC (permalink / raw)
  To: git@vger.kernel.org

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-11-05  0:54 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-04 15:59 git-add ignores exclude markers for ignored files Rahn, René
2025-11-04 22:11 ` Junio C Hamano
2025-11-05  0:54   ` Junio C Hamano

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).