Last Updated: February 25, 2016
· forivall

Fixing a corrupt local git repository

So last week, our git server was having issues and something got corrupted. Whenever I tried to fetch, I would get the following error message:

fatal: internal server error
remote: internal server error
fatal: protocol error: bad pack header

No amount of git fsck or git gc would fix the issue. The remote (gerrit) server was fixed, but was still some kind of unfixable corruption in my local objects.

The solution that other co-workers made was to make a completely new clone of the repository, but I didn't want to bother with the extra work that would entail, so I did this instead:

cp .git/config .git/config.backup
git remote remove origin
mv .git/config.backup .git/config
git fetch

3 Responses
Add your response


I have the same problem, but this solution doesn't seem to work for me.

over 1 year ago ·

@mmontag Does re-cloning work? There's definitely a lot of ways that git can get corrupted, and its error messages aren't the best. I can't really help any further without more information

over 1 year ago ·

works great!

over 1 year ago ·
Filed Under