Thread (8 messages) flat view 8 messages, 6 authors, 2016-06-15

Re: Recovering from commit --amend in rebase --interactive

From: Gabriel Filion <hidden>
Date: 2016-06-15 22:48:53

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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help