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

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

From
Gabriel Filion <lelutin@gmail.com>
Date
Jun 1, 2010, 15:07 UTC
Message-ID
<4C05223A.7000204@gmail.com>
In-Reply-To
<alpine.DEB.2.00.1006011022030.2352@ds9.cixit.se>
On 2010-06-01 05:27, Peter Krefting wrote:
Show 9 quoted lines
> 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
Previous: Ævar Arnfjörð Bjarmason
Message 8 of 8 in “Recovering from commit --amend in rebase --interactive”
  1. Peter KreftingJun 1, 2010
  2. Boaz HarroshJun 1, 2010
  3. Peter KreftingJun 1, 2010
  4. Jan KrügerJun 1, 2010
  5. Ævar Arnfjörð BjarmasonJun 1, 2010
  6. Junio C HamanoJun 2, 2010
  7. Ævar Arnfjörð BjarmasonJun 3, 2010
  8. Gabriel FilionJun 1, 2010

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.