From: Jon Forrest <nobozo@gmail.com>
To: git@vger.kernel.org
Subject: Repost: Inconsistent Behavior in 'git add' (git 2.52.0)?
Date: Thu, 15 Jan 2026 08:36:49 -0800 [thread overview]
Message-ID: <12239ac3-bc9c-4484-8633-a255a706011c@gmail.com> (raw)
Any response to this?
Should I submit it in a bug report even though it's
probably not a bug?
Thanks,
Jon
---
A while back (6 Sep 2025) I submitted a report about how running
git add x bogus_file
where 'x' exists but 'bogus_file' doesn't results
in 'x' not being added to the index. Peff was kind
enough to explain that the presence of even 1 invalid file invalidates
the whole 'git add' command, no matter how many valid files
are included. OK, fine.
This morning I was experimenting with what happens if a file
is specified on a 'git add' command line where the file exists
but is in a .gitignore file. I was expecting the same behavior
as when the file doesn't exist at all. Here's what happened:
% ls -l file1 jon
-rw-r--r-- 1 jonf 15 Dec 30 15:36 file1
-rw-r--r-- 1 jonf 0 Jan 4 11:19 jon
% git check-ignore -v file1
.gitignore:2:file1 file1
So far, so good. Both file1 and jon exist, but file1 is
in .gitignore. Just for yuks, I start with a clean repo.
% git init
Initialized empty Git repository in /tmp/fish/.git/
The index is empty, as shown by
% git ls-files --cached
%
I then ran
% git add file1 jon
git add file1 jon
The following paths are ignored by one of your .gitignore files:
file1
Again, this is exactly what I expected. But, running
'% git ls-files --cached' shows
jon
This is *not* what I expected. I expected the 'git add' command to
not add anything to the index, the same way it behaved when I tried
to add a file that doesn't exist (see the beginning of this message).
But, apparently specifying a missing file is considered a different
kind of error than specifying an ignored file.
Once again, I'm wondering if this is expected behavior.
Cordially,
Jon Forrest
next reply other threads:[~2026-01-15 16:36 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-15 16:36 Jon Forrest [this message]
2026-01-15 16:55 ` Repost: Inconsistent Behavior in 'git add' (git 2.52.0)? Junio C Hamano
2026-01-18 17:50 ` Jon Forrest
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=12239ac3-bc9c-4484-8633-a255a706011c@gmail.com \
--to=nobozo@gmail.com \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox