git fetch insufficient permission for adding an object to repository database .git/objects?

Jistanidiot picture Jistanidiot · Oct 25, 2012 · Viewed 7.1k times · Source

In my repo in my home directory (on an Ubuntu box) I did

 git fetch

I unfortunately got an error about:

 insufficient permission for adding an object to repository database .git/objects

There's a gazillion directories in .git/objects and all of them appear to be 775. The few spot checks I did show the files to be 664.

I went and did a

 chmod -R 777 .git/objects 

which fixed the problem but now I've got a bunch of files 777 on my box and I'm sure that's a no-no.

What should the correct permissions be and how can I easily get all 10 million files and directories set correctly?

Thanks in advance.

Answer

gahooa picture gahooa · Oct 25, 2012

Are you the owner of all the files?

Try

chown -R you:you .git

Then chmod them to "normal"

chmod -R u=rwX,g=rwX,o=