On Wed, 20 Jun 2012 18:52:52 -0700 (PDT)
Git User <usv299792...@gmail.com> wrote:

> One more question.
> Is there an option to commit only specified files in their staged
> state without doing `git add' on them ?
There's a contradiction in your question: "the staged state" is
the state of the files as recorded in the staged area (in the index),
and the current (as in the work tree) state of files gets recorded in
the index by doing `git add` on those files.

A simple example (suppose the aaa.txt file did not exist):

$ echo one > aaa.txt
$ git add aaa.txt

At this point, aaa.txt is recorded in the index.
It's staged state is no different than its current state.

$ echo two >> aaa.txt

At this point, the staged state of aaa.txt is different
from its current state as this file has been modified
in the work tree, but the changes were not recorded.

If you do `git commit` at this point, the staged state will be
recoded, not the current stage (what's in the work tree).

I also can imagine that you actually wanted to ask "is there a way to
commit the state of a set of files as present in the work tree without
going through adding them to the index?".  If this is indeed the case,
then the answer is "yes".
First, you can use
$ git commit -- <file1> [<file2> ...]
which will effectively do `git add` on the specified files and then
commit the changes.
Second, you can do `git add -u` to record changes in all tracked files
to the index.
Third, you can do
$ git commit -a
which effectively is `git add -u` + `git commit`.

You received this message because you are subscribed to the Google Groups "Git 
for human beings" group.
To post to this group, send email to git-users@googlegroups.com.
To unsubscribe from this group, send email to 
For more options, visit this group at 

Reply via email to