Subject: Re: [feature request] allow directly committing untracked files

From: "brian m. carlson" <[email-masked]>
Date: Sat, 23 Aug 2025 15:43:56 +0000

On 2025-08-23 at 06:45:30, Isaac Oscar Gariano wrote:
> I often use 'git commit some-file -m 'some message'" to quickly make a commit, but this is annoying as it doesn't work if some-file is untracked, you first have to do 'git add some-file'.
> It would also be nice to do this with the `-a` option as well.
> Is there any reason why git does not let you do this?

I think we've seen a request for this before.

I will say that I always stage changes ahead of time because I'll often
work on a few different things before committing[0] and I always want to
be very sure what I'm including, but I know not everyone does that.
It's also the case that sometimes files end up not being properly
ignored[1], so it's very easy to accidentally include files that you
wouldn't ever want to commit.

> Would people be open to me making a patch that ads this? Would it need to be behind an option for backwards-compatibility?

I can see that it would be useful.  For instance, it could be convenient
when writing tests of Git's behaviour where you really want to just
include everything in the directory.

It would definitely need to be behind an option.  I might suggest
something like this:

    git commit --include-untracked -m "message" some-file

Of course, we typically reserve a final opinion on a change until we see
a patch, since we're interested in both the idea behind the feature and
the implementation.

[0] For instance, at work, I was fixing some software tests to run
properly with reftable and I fixed several different files before
committing, each of which would have needed to be its own commit.
[1] I've seen this in codebases in which tests are only infrequently run
by hand and where the CI doesn't care about untracked files.
-- 
brian m. carlson (they/them)
Toronto, Ontario, CA