On Thu, 14 Mar 2013 18:38:16 -0700 (PDT)
joeriel...@gmail.com wrote:

> >> > How do I reset one working file, but leave the index alone?  git 
> >> checkout 
> >> > file does not do that 
> >> > (it appears to do nothing), nor does git checkout -- file. 
> >> > 
> >> > To clarify, I've edited a file, then added it to the index. I
> >> > now want to leave the change in the index, 
> >> > but reset the working file to the checked-in version.   
> >>
> >> git checkout HEAD -- file 
> >
> > That does not work.  It resets the index and the working space. 

Sorry for confusion.

> It is surprising that this doesn't work, the help page for checkout 
> specifically discusses this case. 
> Regardless, it doesn't work, the version of file that was added to
> the index no longer exists in the index.

No, it actually behaves as documented, and my citation of the manual
was incomplete.  It really goes like this (note the last sentence):

  When <paths> or --patch are given, git checkout does not switch
  branches. It updates the named paths in the working tree from the
  index file or from a named <tree-ish> (most often a commit).
  The <tree-ish> argument can be used to specify a specific tree-ish
  (i.e. commit, tag or tree) to update the index for the given paths
  before updating the working tree.

I think it's also interesting to cite the `git reset` manual
(the last sentence is, again, the most interesting):

  git reset [-q] [<commit>] [--] <paths>…

    This form resets the index entries for all <paths> to their state
    at <commit>. (It does not affect the working tree, nor the current
    After running git reset <paths> to update the index entry, you can
    use git-checkout(1) to check the contents out of the index to the
    working tree. Alternatively, using git-checkout(1) and specifying a
    commit, you can copy the contents of a path out of a commit to the
    index and to the working tree in one go.


You received this message because you are subscribed to the Google Groups "Git 
for human beings" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to git-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to