git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
KHKristoffer Haugsbakk <kristofferhaugsbakk@fastmail.com>
Date
May 27, 2025, 16:43 UTC
Message-ID
<09518eac-948e-46be-9cd2-64304e78af81@app.fastmail.com>
In-Reply-To
<1014npb$rbl$1@ciao.gmane.io>
On Tue, May 27, 2025, at 18:03, 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 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.

Also note the commit message.  It doesn’t sound like an endorsement.
I have also not seen anyone really recommend using this option.
† 1: f0b32737ad5 (Add "git commit --all" since everybody seems to want
    it., 2005-07-19)
† 2: And the documentation that you saw was added in cb95bf488b4
    (Documentation: git-commit -a, 2006-01-13)
† 3: index: also known as staging area
>
> Would the addition of "git commit -A" (note the capital letter)
> that works the same as "git commit -a", except that new files
> are also added be something you'd consider?
-- 
Kristoffer Haugsbakk
Previous: Jon ForrestNext: Junio C Hamano
Message 5 of 7 in “"git commit -a" Doesn't Add New Files. Why?”
  1. Jon ForrestMay 27, 2025
  2. Nico WilliamsMay 27, 2025
  3. Junio C HamanoMay 28, 2025
  4. Jon ForrestMay 28, 2025
  5. Kristoffer HaugsbakkMay 27, 2025
  6. Junio C HamanoMay 28, 2025
  7. Junio C HamanoMay 28, 2025

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.