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 -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html