Correcting a Git corruption problem

Sometimes when we work with submodules the wrong way we end corrupting the repository and after trying to pull the server we get:

error: git-upload-pack: git-pack-objects died with error.
fatal: git-upload-pack: aborting due to possible repository corruption on the remote side.
remote: Generating pack…
remote: Done counting 39 objects.
remote: Result has 28 objects.
remote: error: unable to find b490fa1a6d81e39d3a8d99f9cce8b57c3397b7d7
remote: fatal: unable toremote: aborting due to possible repository corruption on the remote side.
fatal: protocol error: bad pack header

I’m not sure if this is the best solution but pulling from the public URL and then pushing to the server solves the problem.