Subject: Re: "git commit -a" Doesn't Add New Files. Why?

From: Junio C Hamano <[email-masked]>
Date: Wed, 28 May 2025 15:24:02 -0700

Nico Williams <[email-masked]> writes:

> On Tue, May 27, 2025 at 09:03:55AM -0700, Jon Forrest wrote:
>> The documentation clearly says that running "git commit -a"
>> doesn't add new files to the index. I wonder why that choice
>> was made.
>
> I use `git commit -a` all the time in workspaces that are dirty.  It
> would be exceedingly annoying if `git commit -a` were to act like `git
> add . && git commit`.

True, but not quite.  You would want your "git add ." to be safe in
dirty working trees---at least some folks wanted so badly enough
that "git add ." pays attention to the ".gitignore" mechanism.

But `git commit -a` would not change, even if it won't add cruft
with well curated .gitignore files.  That will be a terrible
backward incompatible change for those who expect it only deals with
the files it knows about (including the one that is not yet tracked
but its presence is known via "git add -N").