On Fri, May 03, 2013 at 02:27:44PM -0700, Dimitar Bonev wrote:

> > > > Is there a git porcelain command to revert the working dir state of a 
> > > > staged file to its HEAD state and at the same time keep the staged 
> > state of 
> > > > the file? 
> >
> > git show HEAD:$FILE >$FILE 
> >
> This has drawback as it uses console redirection so it depends on the 
> console output. On Windows PowerShell has some 
> issues<http://stackoverflow.com/questions/13675782/git-shell-in-windows-patchs-default-character-encoding-is-ucs-2-little-endian>
>  with 
> output encoding. I guess it will work just fine on Ubuntu, however I should 
> test it to make sure it works for non-english language encodings.

This should also work in plain cmd.exe, Git bash and other 3rd-party
implementations like Console.

The fact Git for Windows calls Git bash to handle aliases involving a
shell (those which start with a `!' character) might be employed to
create an alias for your case:

git config --add --global alias.ckout \
        "!set -e -u && git show \"HEAD:$1\" >\"$1\""

Should allow you to do

git ckout filename

P.S.
By the way, those who are interested in how this discussion continued on
the main Git list but are not subscribed to it may read [1].

1. 
http://news.gmane.org/find-root.php?group=gmane.comp.version-control.git&article=223357

-- 
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