Repair Git Link After Fatal Error

I recently had to perform a hard reboot, and now I get an error message in git when trying to access a specific branch (this does not happen when accessing other branches):

$git checkout branchName fatal: failed to read object ebca165c3ec7ecd7124f41983dd264e4e1dc0125: Invalid argument 

The problem is similar to that described here: How to repair a damaged git repository? , but different in that I am not currently running git status . Also, if I call git reflog , I get the same error message.

I tried to remove the branch in question using git branch -d branchName and git branch -d branchName , but was unsuccessful.

Obviously, I would like to keep all the branches and data, but if the solution is to delete this particular branch, then this is normal. In addition, I do not know if this helps or even matters, but the last action performed on this branch was rebase .

Can a possible solution restore the current ref from each of the individual branches that exist, with the exception of an invalid branch?

As a side note, I do not have a remote source from which it is more convenient for me to clone ing from now on, so any local solutions are required. In addition, I use PHP in case this matters for any reason.

Thanks.


Edit:

Running git fsck --full Received the following message:

 $git fsck --full fatal: failed to read object 687f624bd239de165307d18a8904a77adb32c8a1: Invalid argument 

... which is odd because it seems to refer to another hash.

+4
source share
1 answer

I finally found out how to answer this question ...

Just go to the .git folder and delete refs/heads/BadBranch

This allows the rest of the branch es to work as they normally should, but only lose information from the damaged branch .

0
source

Source: https://habr.com/ru/post/1399066/


All Articles