git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: How to undo git-rm?

From
Jakub Narebski <jnareb@gmail.com>
Date
Mar 20, 2008, 00:49 UTC
Message-ID
<m31w66w76k.fsf@localhost.localdomain>
In-Reply-To
<20080318230441.GA664@arctrix.com>
Neil Schemenauer <nas@arctrix.com> writes:
Show 7 quoted lines
> 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
Previous: Junio C HamanoNext: Elijah Newren
Message 3 of 5 in “How to undo git-rm?”
  1. Neil SchemenauerMar 18, 2008
  2. Junio C HamanoMar 20, 2008
  3. Jakub NarebskiMar 20, 2008
  4. Elijah NewrenMar 20, 2008
  5. Elijah NewrenMar 20, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.