Re: [feature request] allow directly committing untracked files

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

Attachment: signature.asc
Description: PGP signature


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux