5

We recently changed the location of a repository, and we discovered a months-old commit is missing from the files. The old server we had the Git on is down, so there is no chance of recovering the commit from there.

Here's the error I get:

$ git fsck --full
broken link from commit 58ba71d080b1814420bce09c4e505b323fd9cb58
to commit a2e2bde363032b7609616a3152fe048cc5c83715

missing commit a2e2bde363032b7609616a3152fe048cc5c83715

Is there anything that can be done to fix this? Thank you!

2 Answers 2

10

Every clone has full history so anyone who worked on that project since the commit was published should have it on their computer. Look inside anyone's working directory for the commit then add it's packs and objects (content of the .git/objects directory) to the broken repository (only files that don't exist), fsck again and repack.

It's not possible to reconstruct the object if you don't find it anywhere.

Sign up to request clarification or add additional context in comments.

3 Comments

If nobody has this particular object, is there some way to remove it from git?
@Albert: The ID of commit (or anything else) is a cryptographically strong hash of the whole history leading to it, so you can't remove anything from it. You can, however, use git filter-branch to create an alternate history without whatever you need to exclude. Everybody needs to switch to the new history afterwards.
Comment update: there is now git filter-repo, which is a faster and slightly easier to use replacement for the standard git filter-branch.
-8

Remove the .git directory from application directory. Create the new one using "git init" inside your application root directory and continue with

"git add ."
"git commit -m your comment" 
"git push origin master"

Hope this will work!!!

1 Comment

This will likely ruin your chances of sanely rebasing you missing commit. Learned the hard way.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.