My git repository is in a bad shape after a power cut.
I would like to save this git repository because I have local branches that only exist in this local repository.
$ git co master
error: Your local changes to the following files would be overwritten by checkout:
some_file
another_file
All the files in the repository appear new and yet, they are just the same as before:
$ git status
On branch my_branch
Initial commit
Changes to be committed:
(use "git rm --cached <file>..." to unstage)
new file: .gitignore
new file: BUILD.md
new file: CONTRIBUTING.md
new file: README.md
new file: STYLE.md
...
new file: pom.xml
new file: rename.py
I have this too:
$ git gc
error: Could not read e39f7f1d41e57c37f22d09c005d660258bbc6343
fatal: bad tree object e39f7f1d41e57c37f22d09c005d660258bbc6343
error: failed to run repack
$ git log
fatal: your current branch 'my_branch' does not have any commits yet
$ git log master -2
commit e98facb7a7fdcb9f7d82955db15a7c120d140170
Author: Jean-Noël Rouvignac
Date: Thu Sep 13 16:00:38 2018 +0200
...
commit 962fc48c67aebdc847ccb8af3c76ce1996b0fe46
Author: Jean-Noël Rouvignac
Date: Thu Sep 13 15:04:02 2018 +0200
...
$ git log HEAD
fatal: ambiguous argument 'HEAD': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'
$ cat .git/HEAD
ref: refs/heads/my_branch
$ cat .git/logs/refs/heads/my_branch
0000000000000000000000000000000000000000 e98facb7a7fdcb9f7d82955db15a7c120d140170 Jean-Noël Rouvignac 1536927392 +0200 branch: Created from HEAD
e98facb7a7fdcb9f7d82955db15a7c120d140170 96a7d8563363b15b91bdd5c2724007cc8c036bcd Jean-Noël Rouvignac 1536927529 +0200 commit: some commit
96a7d8563363b15b91bdd5c2724007cc8c036bcd 9d393e866cf3dd07d307f537c632ca5176e7c1a9 Jean-Noël Rouvignac 1536927741 +0200 commit (amend): some commit
9d393e866cf3dd07d307f537c632ca5176e7c1a9 bff18f48aa48e06f438fb313b1fa5fba00ff15f1 Jean-Noël Rouvignac 1536930612 +0200 commit: another commit
bff18f48aa48e06f438fb313b1fa5fba00ff15f1 563fe6ce2c56bb078fb2b77c3b95f9ee35fb8d20 Jean-Noël Rouvignac 1536930614 +0200 cherry-pick: another commit yet
563fe6ce2c56bb078fb2b77c3b95f9ee35fb8d20 fb859a42f3e3115c15e618193285666c6c26a45e Jean-Noël Rouvignac 1536930625 +0200 rebase -i (finish): refs/heads/my_branch onto bff18f48aa48e06f438fb313b1fa5fba00ff15f1
fb859a42f3e3115c15e618193285666c6c26a45e 9bde6d1f18b3abbbb85c8292ac317595a07671a1 Jean-Noël Rouvignac 1536931081 +0200 commit (amend): another commit
9bde6d1f18b3abbbb85c8292ac317595a07671a1 509667f1e8b0ea3551b18675322fed7559c2b0fd Jean-Noël Rouvignac 1536931501 +0200 commit (amend): another commit
509667f1e8b0ea3551b18675322fed7559c2b0fd c76770fe2986ccfe24bfb76847d9c037f4bad65b Jean-Noël Rouvignac 1536931578 +0200 commit (amend): another commit
c76770fe2986ccfe24bfb76847d9c037f4bad65b 10c7f4fe48c29668268bcf956620ce09f367b183 Jean-Noël Rouvignac 1536932495 +0200 commit (amend): another commit
10c7f4fe48c29668268bcf956620ce09f367b183 94de94f1e1df660730ed7846f1e6d5bd76f50abe Jean-Noël Rouvignac 1536933394 +0200 commit (amend): another commit
94de94f1e1df660730ed7846f1e6d5bd76f50abe 6386448321ac4b49e8e8fb65e1494d5f3307f5d8 Jean-Noël Rouvignac 1536938691 +0200 cherry-pick: DO NOT MERGE
6386448321ac4b49e8e8fb65e1494d5f3307f5d8 37d78592e6179b1c07c181e469310bcdd74322bb Jean-Noël Rouvignac 1536950131 +0200 commit: fixup
The repository is important to me, so I would like to save it.
Has anybody got an idea on what could go wrong and how to fix it?
I am a bit lost on what to do now.