How to undo git-rm?

4 messages, 3 authors, 2016-06-15 · open the first message on its own page

How to undo git-rm?

From: Neil Schemenauer <hidden>
Date: 2016-06-15 22:44:24

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

Re: How to undo git-rm?

From: Jakub Narebski <hidden>
Date: 2016-06-15 22:44:24

Neil Schemenauer [off-list ref] writes:
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.
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

Re: How to undo git-rm?

From: Elijah Newren <hidden>
Date: 2016-06-15 22:44:24

On Tue, Mar 18, 2008 at 5:04 PM, Neil Schemenauer [off-list ref] wrote:
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.
Try
  git checkout HEAD eg
or
  git show HEAD:<path> > <path>

Re: How to undo git-rm?

From: Elijah Newren <hidden>
Date: 2016-06-15 22:44:24

On Wed, Mar 19, 2008 at 8:53 PM, Elijah Newren [off-list ref] wrote:
On Tue, Mar 18, 2008 at 5:04 PM, Neil Schemenauer [off-list ref] wrote:
 > 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.

 Try
  git checkout HEAD eg
doh, that should be
  git checkout HEAD <path>
of course.
 or
  git show HEAD:<path> > <path>
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help