I broke my local git repository by interrupting a git commit
with Ctrl+C (two commits back).
How can I fix it ?
Output of git stash
:
$ git stash
fatal: bad revision 'HEAD'
fatal: bad revision 'HEAD'
fatal: Needed a single revision
You do not have the initial commit yet
Output of git fsck --lost-found
:
$ git fsck --lost-found
notice: HEAD points to an unborn branch (Multi-Threading)
Checking object directories: 100% (256/256), done.
Checking objects: 100% (67/67), done.
error: refs/heads/Multi-Threading: invalid sha1 pointer 0000000000000000000000000000000000000000
dangling commit 2d5af11417b9508ece28c1bb1502e5299a2fa2d0
dangling commit 3b0dfd77c49c12a23469c036db7f45378a1bf740
dangling commit 47d212cf4c018b9f3544325a26c90f74d3323489
dangling commit 82674535931943f64b4a3475c14475591d84a318
dangling commit 83604cf338ccb0491081f7f27c2217bc11fba0c2
dangling blob a3133e60fe8fec7977270d1e93c0869e169024f1
dangling commit aae880196744421d1ffbf7dc23aa8965d4ee1f46
dangling blob e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
dangling commit f9558f1235c4a239b2c8d0677d2b1c31eb400836
Output of git reflog
:
$ git reflog
fatal: your current branch 'Multi-Threading' does not have any commits yet
It's also impossible to write in .git/refs/heads/Multi-Threading
:
$ echo 47d212cf4c018b9f3544325a26c90f74d3323489 > .git/refs/heads/Multi-Threading
An error occurred while redirecting file '.git/refs/heads/Multi-Threading'
open: No such file or directory
My problem was due to a system error.
I restarted, re-executed echo 47d212cf4c018b9f3544325a26c90f74d3323489 > .git/refs/heads/Multi-Threading
without error and it fixed my issue.