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

From: Junio C Hamano <[email-masked]>
Date: Wed, 28 May 2025 14:16:03 -0700

"Kristoffer Haugsbakk" <[email-masked]> writes:

> I think it makes sense to only include tracked files.  But (in any case)
> when the option was added[1][2] it meant:
>
>     git-diff-files --name-only | xargs git-update-cache
>     git commit
>
> And this `git diff-files --name-only` prints tracked files which
> are changed.
>
> Given that you apparently had to pipe filenames to a command that
> updates the cache (obsolete for: index[2]) and then do a commit I will
> assume that mistakes were more costly.  What if you piped in all changed
> tracked files and untracked files?  And you forgot to ignore your build
> artifacts?  That’s more things you have to undo.

But .gitignore is your friend these days.

Given that a precursor of modern "gitignore" did not appear until
fee88256 (ls-files: rework exclude patterns., 2005-07-28), and "git
status" started to pay attention only at ba966b95 (Teach
git-status-script about git-ls-files --others, 2005-08-26), it is
understandable that nobody was enthused about grabbing any new files
out of the working tree back then.

And unless you are total newbie, you would know that you create a
new file far far less often than you modify an existing file, so you
would be more careful about avoiding to include new and unwanted
files than forgetting to add new and necessary files.