From: "Konstantin Khomoutov" <flatw...@users.sourceforge.net>
Cc: "Git User" <usv299792...@gmail.com>
Sent: Friday, June 22, 2012 2:40 PM
Subject: Re: [git-users] Re: Documentation discrepancy
On Thu, 21 Jun 2012 18:06:29 -0700 (PDT)
Git User <usv299792...@gmail.com> wrote:
Here is what I meant:
echo alpha > a.txt
echo beta > b.txt
echo gamma >> b.txt
Now I have a.txt and b.txt in staged state; and b.txt also has
I want to commit ONLY b.txt (i.e. I want to commit only 'beta' and
leave b.txt in modified state with 'beta' & 'gamma' in it, 'gamma'
being showed as '+gamma' in `git diff'.
Something like `git commit --staged b.txt'
In other words, how do we `git commit' just one file from the index
if there are more than one files in the index.
I think you can't as you effectively wish to have one more level of
indirection (the second index).
I can imagine various workarounds to achieve what you want but they
are imperfect in one way or another.
The proper way to do this probably would be to write your own
command that would:
1) Save a list of files with staged changes.
2) Reset all of the staged entries except for those files you
If any file to reset has unstaged local changes, refuse to proceed.
4) Re-add the files that were reset on step (2).
Also have a look at what `git stash` can do for you in terms of taking a
snapshot of your current 'dirty' working tree and then giving you a
chance to checkout any commit or branch you wanted, and pick stuff out
of the stash to create the commit wou want, and then pop the stash.
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 firstname.lastname@example.org.
To unsubscribe from this group, send email to
For more options, visit this group at