# How to undo git-rm?

5 messages from 2008-03-18 to 2008-03-20. Participants: Neil Schemenauer, Junio C Hamano, Jakub Narebski, Elijah Newren.
Thread: https://gitlist.dev/t/12768

## Neil Schemenauer, 2008-03-18 23:04

Subject: How to undo git-rm?
Message-ID: <20080318230441.GA664@arctrix.com>
URL: https://gitlist.dev/e/20080318230441.GA664%40arctrix.com

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

```

## Junio C Hamano, 2008-03-20 00:24

Subject: Re: How to undo git-rm?
Message-ID: <7v63vi1bvj.fsf@gitster.siamese.dyndns.org>
URL: https://gitlist.dev/e/7v63vi1bvj.fsf%40gitster.siamese.dyndns.org
In-Reply-To: <20080318230441.GA664@arctrix.com>

```
Neil Schemenauer <nas@arctrix.com> writes:

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

"git checkout HEAD -- that-path"?

```

## Jakub Narebski, 2008-03-20 00:49

Subject: Re: How to undo git-rm?
Message-ID: <m31w66w76k.fsf@localhost.localdomain>
URL: https://gitlist.dev/e/m31w66w76k.fsf%40localhost.localdomain
In-Reply-To: <20080318230441.GA664@arctrix.com>

```
Neil Schemenauer <nas@arctrix.com> 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

```

## Elijah Newren, 2008-03-20 02:53

Subject: Re: How to undo git-rm?
Message-ID: <51419b2c0803191953y7842ddf8l7a6de37226cb12e2@mail.gmail.com>
URL: https://gitlist.dev/e/51419b2c0803191953y7842ddf8l7a6de37226cb12e2%40mail.gmail.com
In-Reply-To: <20080318230441.GA664@arctrix.com>

```
On Tue, Mar 18, 2008 at 5:04 PM, Neil Schemenauer <nas@arctrix.com> 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>

```

## Elijah Newren, 2008-03-20 02:54

Subject: Re: How to undo git-rm?
Message-ID: <51419b2c0803191954q1811c351jc65ff1ac541f07a2@mail.gmail.com>
URL: https://gitlist.dev/e/51419b2c0803191954q1811c351jc65ff1ac541f07a2%40mail.gmail.com
In-Reply-To: <51419b2c0803191953y7842ddf8l7a6de37226cb12e2@mail.gmail.com>

```
On Wed, Mar 19, 2008 at 8:53 PM, Elijah Newren <newren@gmail.com> wrote:
> On Tue, Mar 18, 2008 at 5:04 PM, Neil Schemenauer <nas@arctrix.com> 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>

```
