How to undo git-rm?

Previous thread: [PATCH] New test for preserve merges and squash by Jörg Sommer on Wednesday, March 19, 2008 - 5:03 pm. (8 messages)

Next thread: none
From: Neil Schemenauer
Date: Tuesday, March 18, 2008 - 4:04 pm

Hi,

This seemingly simple operation has me stumped.  I removed something
from my try using "git rm" and now I want it back.  With SVN I would
use "svn cat <path> > <path>".  After some searching around, I
though git-cat-file would do the trick.  Alas, it appears as though
it looks up the SHA for the path in the index and so it too fails.

  Neil
--

From: Junio C Hamano
Date: Wednesday, March 19, 2008 - 5:24 pm

"git checkout HEAD -- that-path"?
--

From: Jakub Narebski
Date: Wednesday, March 19, 2008 - 5:49 pm

Direct equivalent would be

  $ git show HEAD:<path> > <path>   # from last commit
  $ git show :<path>     > <path>   # from index

but actually you would probably use

  $ git checkout -- <path>

-- 
Jakub Narebski
Poland
ShadeHawk on #git
--

From: Elijah Newren
Date: Wednesday, March 19, 2008 - 7:53 pm

Try
  git checkout HEAD eg
or
  git show HEAD:<path> > <path>
--

From: Elijah Newren
Date: Wednesday, March 19, 2008 - 7:54 pm

doh, that should be
  git checkout HEAD <path>
--

Previous thread: [PATCH] New test for preserve merges and squash by Jörg Sommer on Wednesday, March 19, 2008 - 5:03 pm. (8 messages)

Next thread: none