I was attempting a repeated git filter branch which left a final message saying refs/heads/master is unchanged
. I read that it was because a backup already existed so I had to get rid of it. So I ran git update-ref -d refs/heads/master
and now there are no commits anymore and I can't seem to undo this. Any suggestions?
Asked
Active
Viewed 1,386 times
3

RespectableSlave
- 51
- 7
-
The `update-ref` subcommand has no `--delete` option. What is the exact command you ran? – jub0bs Apr 27 '18 at 12:43
-
1My bad I meant `-d` which deletes the reference – RespectableSlave Apr 27 '18 at 12:52
1 Answers
2
I managed to fix this by reading this Stack Overflow question and the subsequent link in the comment: Recovering Git repository from objects only.
use
git fsck
to find a list of dangling commit hashesvim into your
.git/refs/heads/master
which is just a text file and enter the suspected hash which represents your latest commit for master.save and go back to the root directory to inspect the git log to see if that is your latest. If not then systematically go through the hashes from step 1 until you found it.
after finding it
git checkout .
so git reverts to the original state of the master branch

jub0bs
- 60,866
- 25
- 183
- 186

RespectableSlave
- 51
- 7