git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Gabriel Filion <lelutin@gmail.com>
To: Peter Krefting <peter@softwolves.pp.se>
Cc: Git Mailing List <git@vger.kernel.org>
Subject: Re: Recovering from commit --amend in rebase --interactive
Date: Tue, 01 Jun 2010 11:07:38 -0400	[thread overview]
Message-ID: <4C05223A.7000204@gmail.com> (raw)
In-Reply-To: <alpine.DEB.2.00.1006011022030.2352@ds9.cixit.se>

On 2010-06-01 05:27, Peter Krefting wrote:
> Last time this happened to me, I *did* notice my mistake as I entered
> the editor, since it came up with the previous commit's message.
> However, as the commit message file was in a good shape, I found no way
> to break out of the amend. I ended up using "git reflog" to find out
> what I overwrote, then "git diff $commitid > savedpatch" to remember
> what the change that I mistakenly amended was, then "git checkout
> $commitid" and "git apply savedpatch" and "git add" on the changed
> files. What I am wondering if there is an easier way of recovering?
> 

when you amend or rebase commits, the "old" commits are still in your
local git repository as long as you don't "git gc" them. for this, the
reflog can help you find the previous sha1 for the old commit. you can
also use "git fsck --full" to find out which commits were orphaned. once
you have the hashes, you can bring HEAD back to them.

see [1] for some simple examples of data recovery with git.

[1]:http://progit.org/book/ch9-7.html#data_recovery

-- 
Gabriel Filion

      parent reply	other threads:[~2010-06-01 15:07 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-06-01  9:27 Recovering from commit --amend in rebase --interactive Peter Krefting
2010-06-01  9:48 ` Boaz Harrosh
2010-06-01 10:40   ` Peter Krefting
2010-06-01  9:57 ` Jan Krüger
2010-06-01 15:25   ` Ævar Arnfjörð Bjarmason
2010-06-02 23:37     ` Junio C Hamano
2010-06-03  5:54       ` Ævar Arnfjörð Bjarmason
2010-06-01 15:07 ` Gabriel Filion [this message]

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=4C05223A.7000204@gmail.com \
    --to=lelutin@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=peter@softwolves.pp.se \
    /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;
as well as URLs for NNTP newsgroup(s).