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

Re: [Question] Git recovery with HEAD commit broken

From
Matthieu Moy <matthieu.moy@grenoble-inp.fr>
Date
Dec 11, 2013, 15:01 UTC
Message-ID
<vpqzjo7whwj.fsf@anie.imag.fr>
In-Reply-To
<CAP9B-Q=ARp00Bj5zJ0J=3qv9R16YGu5AZgLpqoO0y+cY1at1Zw@mail.gmail.com>
Shilong Wang <wangshilong1991@gmail.com> writes:
> A power off cause my top commit broken, and then git
> branch/log/reflog..etc won't work.

With a bit of luck, the reflog actually contain useful information. Look at .git/logs/HEAD (or refs/heads/* instead of HEAD for branches' reflog). It's a human-readable text format. You should be able to walk up the history looking for a good commit.

> I do a hack that

Before anything else: do a backup of your full repository while it's still time.

> i change the HEAD commit to the one that i can make sure is right,

(don't forget to run "git fsck" to make sure that not only the commit but also its ancestry is right).

> In fact, i hope git fsck can fix up such problems(maybe can backup top
> commit for example)...

Not as far as I know. But "git fsck" has a --lost-found option that can help recovering unreachable (dangling) commits.

You may have a look at http://hackage.haskell.org/package/git-repair but I do not think it would solve your particular case.

-- 
Matthieu Moy
http://www-verimag.imag.fr/~moy/
Previous: Shilong WangNext: Joey Hess
Message 2 of 4 in “[Question] Git recovery with HEAD commit broken”
  1. Shilong WangDec 11, 2013
  2. Matthieu MoyDec 11, 2013
  3. Joey HessDec 11, 2013
  4. Jonathan NiederDec 11, 2013

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.