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

Re: Git screwup with reset

From
Shawn O. Pearce <spearce@spearce.org>
Date
May 18, 2009, 15:08 UTC
Message-ID
<20090518150840.GJ30527@spearce.org>
In-Reply-To
<9D569322-6A7B-4447-962C-0C740945E227@orgsync.com>
jake varghese <jake@orgsync.com> wrote:
> When I run git fsck --lost-found i get a whole bunch of dangling  
> objects.  If I run git show on those objects it shows me the code that 
> was lost.  Anyone know of a way to get this stuff back.  I tried  
> rebasing and merging and neither worked.
For each of those dangling blobs:
  git cat-file blob $sha1 >$path

where you need to manually figure out the relationship between $sha1 and the local $path within your project. Git doesn't have that relationship data, because you never made a commit.

Oh, and next time, commit like every hour, or more frequently than that. At worst, you'll need to do a "git merge --squash" near the end to flatten out your silly "save my work" checkpoints and draft a more useful commit message for your coworkers. But at least you lose less when you have a "git reset --hard" fat finger accident.

-- 
Shawn.
Previous: jake vargheseNext: Sverre Rabbelier
Message 2 of 3 in “Git screwup with reset”
  1. jake vargheseMay 18, 2009
  2. Shawn O. PearceMay 18, 2009
  3. Sverre RabbelierMay 18, 2009

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.