Git problem: error: unable to create temporary sha1 filename

I got git problem: error: unable to create temporary sha1 filename when pushing to a remote repository. The fix is rather easy.

On both your local and remote repositories perform the following magic:

git fsck
git prune
git repack
git fsck

The last fsck should not report any problems.

  • Twitter
  • Digg
  • del.icio.us
  • DZone
  • Reddit
  • email

3 Responses to “Git problem: error: unable to create temporary sha1 filename”

  1. You may also need to chown git:git /pah/to/repos on your server. But this is most likely not the reason for the above error.

  2. Robert says:

    This error message can be caused by incorrect ownership of git files in the local repo as well.

    I personally ran into it during a git commit on a local copy. I eventually tracked it down to the fact that someone had erroneously done a git commit as root at some point. Recursively chowning the project_name/.git directory to its correct owner (in this case, the owner of the local copy) fixed the problem, and the fsck/repack sequence cleaned out the remaining symptoms.

  3. @Robert: Great tip! Thanks!

Leave a Reply