I have restored a git repo from backup and it does not have the correct file permissions. Is it enough to set owner +rw on all files and directories in .git, or is it more subtle?
Is there a utility to check or reset .git file permissions?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Directories should have 755 permission; files should have 644 permission.
That’s a pretty good rule of thumb unless you expect members of your group to make changes to your repository.
Having said that, in one of my repositories, the files under
.git/objects/*have 444 (readonly) permission for everyone. Other files are 644 as suggested.This script, run in the top-level directory just above the
.gitrepository would fix the permissions:I started with
-print0for the first twofindcommands andxargs -0to allow for the remote possibility of spaces in file names. But thegrep -vin the third command would be difficult to manage with the-print0format – so I omitted the space-safe notation from all the commands, knowing thatgitdoes not create files with spacing in names under the.gitdirectory.