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

Re: Recovering from an aborted git-rebase?

From
Shawn O. Pearce <spearce@spearce.org>
Date
Jan 9, 2007, 23:29 UTC
Message-ID
<20070109232949.GB30023@spearce.org>
In-Reply-To
<45A42341.8040304@midwinter.com>
Steven Grimm <koreth@midwinter.com> wrote:
> Got this from one of the other people here who's using git. Luckily he 
> was able to restore his repo from a filesystem snapshot, so no permanent 
> harm done, but what's the pure-git way to recover from this? Are the 
> revisions in question really gone?
Try `git lost-found` before you use `git prune` (or also now `git gc`).

Also, if you have relogs enabled on your work branches (and I hope you do, as its now the default) you can look at the branch from earlier, e.g.:

	git log HEAD@{5.minutes.ago}
or
	git log HEAD@{1}

to look at HEAD was just before `git rebase` did the reset. Which would be the commit you lost, but want back.

Unfortunately we don't really have a reflog viewing utility yet so
you just have to sort of guess around with the @{...} syntax to find
what you are looking for.  But if you can locate the correct SHA1
for the last commit you want back you can do a `git reset --hard $sha1`
to restore your working branch, then do the rebase the way you meant to.
 
-- 
Shawn.
Previous: Steven GrimmNext: Junio C Hamano
Message 2 of 4 in “Recovering from an aborted git-rebase?”
  1. Steven GrimmJan 9, 2007
  2. Shawn O. PearceJan 9, 2007
  3. Junio C HamanoJan 10, 2007
  4. Steven GrimmJan 10, 2007

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.