I got a transaction interrupted and when I try again I was having error with objects that were empty or corrupted, following another question I delete all the empty files and when I run
git fsck --full
I got this error:
Checking object directories: 100% (256/256), done.
Checking objects: 100% (48774/48774), done.
error: d193ccbc48a30e8961e9a2515a708e228d5ea16d: invalid sha1 pointer in cache-tree
error: df084ac4214f1a981481b40080428950865a6b31: invalid sha1 pointer in cache-tree
broken link from tree 4bf4869299b294be9dee4ecdcb45d2c204ce623b
to tree df084ac4214f1a981481b40080428950865a6b31
broken link from tree 4bf4869299b294be9dee4ecdcb45d2c204ce623b
to tree d193ccbc48a30e8961e9a2515a708e228d5ea16d
missing tree df084ac4214f1a981481b40080428950865a6b31
missing blob a632281618ca6895282031732d28397c18038e35
missing tree d193ccbc48a30e8961e9a2515a708e228d5ea16d
missing blob 70aa143b05d1d7560e22f61fb737a1cab4ff74c6
missing blob c21c0545e08f5cac86ce4dde103708a1642f23fb
missing blob 9f341b8a9fcd26af3c44337ee121e2d6f6814088
missing blob 396aaf36f602018f88ce985df85e73a71dea6f14
missing blob 87b9d1933d37cc9eb7618c7984439e3c2e685a11
How can I fix this problem?
Git
Your repository is already broken. Don't break it any further without first making sure nobody can access it except you, making a backup (tar, rsync) of the repository and first trying the commands in a copy of the repository. All the files in .git are gone!
Here's an example of recovering the master branch: The reflog in .git/logs/HEAD can show you which branch you had last checked out. This can help you update the HEAD ref. If you do not have any reflogs, you can still recover refs by looking at your commit objects.
This is one of the very few times where touching files inside .git is OK. If you know which branch you had checked out, you can simply put that information inside .git/HEAD. I had the master branch checked out before deleting the HEAD file. If you don't know which branch (or even commit in detached HEAD state) you had checked out, try a few.
The reflog in .git/logs/HEAD can show you which branch you had last checked out. This can help you update the HEAD ref. If you do not have any reflogs, you can still recover refs by looking at your commit objects. If a commit has no descendants, it could be at the tip of a branch, so a ref should point to it.
git gc --aggressive
will clean up unnecessary files and optimize the local repository.
You can verify that the problem is fixed with:
git fsck --full
What worked for me to fix this "broken link" error was the answer from sehe listed here in response to a question about how to fix an unable to find <insert sha1 code here> error.
Like Adam said, recover the object from another repository/clone.
On a 'complete' Git database:
git cat-file -p a47058d09b4ca436d65609758a9dba52235a75bd > tempfile
and on the receiving end:
git hash-object -w tempfile
One important addition would be that between step 1 and 2, it is important to directly transfer the file from one location to the other. In my experience, it didn't work to move the tempfile using Git push and pull.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With