Git development
 help / color / mirror / Atom feed
From: Jeff King <peff@peff.net>
To: Joe Fiorini <joe@faithfulgeek.org>
Cc: git@vger.kernel.org
Subject: Re: Undo git-rm without commit?
Date: Wed, 26 Mar 2008 02:26:35 -0400	[thread overview]
Message-ID: <20080326062635.GC26286@coredump.intra.peff.net> (raw)
In-Reply-To: <D6386C1A-92D3-4E11-8DE6-CC7553211A33@faithfulgeek.org>

On Wed, Mar 26, 2008 at 02:17:18AM -0400, Joe Fiorini wrote:

> I hadn't done a git-commit yet, but I used git-rm thinking it would  
> remove files that I had just added.  Instead, it deleted everything I had 
> added from the disk.  Is there a way to undo this?  I'm doubtful, but 
> would love to not have to rewrite what I was working on.

If by "added" you mean "git add"ed, then yes. The file is hashed and the
blob is put in the object database during the add. Unfortunately,
nothing actually _refers_ to it, so you will have to pick it out
manually by its hash. Try:

  git fsck --lost-found

and then poke around .git/lost-found/other for your missing content.

As an aside, didn't git-rm warn you? While confirming that the command I
was giving you was correct, I did this:

  git init
  echo content >file
  git add file
  git rm file

and got:

  error: 'file' has changes staged in the index
  (use --cached to keep the file, or -f to force removal)

-Peff

  parent reply	other threads:[~2008-03-26  6:27 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-03-26  6:17 Undo git-rm without commit? Joe Fiorini
2008-03-26  6:24 ` Mike Hommey
2008-03-26  6:26 ` Jeff King [this message]
2008-03-26  6:38   ` Joe Fiorini
2008-03-26  6:39     ` Jeff King
2008-03-26  9:48     ` Matthieu Moy

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20080326062635.GC26286@coredump.intra.peff.net \
    --to=peff@peff.net \
    --cc=git@vger.kernel.org \
    --cc=joe@faithfulgeek.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox