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.