# basics - auto staging?

2 messages from 2025-04-30 to 2025-04-30. Participants: Marcin Mikłas, Junio C Hamano.
Thread: https://gitlist.dev/t/63371

## Marcin Mikłas, 2025-04-30 10:18

Subject: basics - auto staging?
Message-ID: <10c9da5c-234c-4a40-bbff-91ba820dd970@wszib.edu.pl>
URL: https://gitlist.dev/e/10c9da5c-234c-4a40-bbff-91ba820dd970%40wszib.edu.pl

```
Hello,

when I execute
git commit file.txt
(by listing file as argumentbut without the -a switch) for a file 
file.txt that I have made changes without staged them in the index, the 
changes are still commited.
Is there a way to make this work like command
git commit
without committing the changes that are not staged in the index?

Best
Marcin


```

## Junio C Hamano, 2025-04-30 16:44

Subject: Re: basics - auto staging?
Message-ID: <xmqqbjsd38h7.fsf@gitster.g>
URL: https://gitlist.dev/e/xmqqbjsd38h7.fsf%40gitster.g
In-Reply-To: <10c9da5c-234c-4a40-bbff-91ba820dd970@wszib.edu.pl>

```
Marcin Mikłas <m.miklas@wszib.edu.pl> writes:

> when I execute
> git commit file.txt
> (by listing file as argumentbut without the -a switch) for a file
> file.txt that I have made changes without staged them in the index,
> the changes are still commited.
> Is there a way to make this work like command
> git commit
> without committing the changes that are not staged in the index?

I do not think there is.

The "git commit --only [<pathspec>...]" mode (which is the default)
was introduced as a variant whose blast radius is much smaller than
the "git commit --include [<pathspec>...]" mode (which was the only
mode before "--only" was introduced), but what you seem to be after
is a mode that is even finer-grained one.

I do not offhand see a reason why such a mode should not exist.  It
would be called the "git commit --cached [<pathspec>...]" mode (that
would be listed next to the existing "--only" and "--include" modes
in the documentation), by taking inspiration from the name of
another command "git diff --cached [<pathspec>...]" (i.e., use only
the contents already added to the index), if we were to add one.



```
