git with a live website
permissions issues
You should be running the web server as a user other than root. Lets assume 'www'. You develop on another machine, and push to a shared repo where the live server also pulls from. However, you will probably log into the server as root or yourself instead of www, yet if you work with files, use git, etc… permissions can get messed up, even if you tell git to ignore permissions in the config file.
tell git this is a shared repository
git config core.sharedRepository group
- –or– if you are initializing one from scratch, you can do
git init –shared=group
disable filemode
I personally disable filemode checks by git since I work across Unix, Mac, and Windows environments. Rather, I set up group sticky bits and umask 2.
git config core.filemode false
make sure the same group is on all subdirs and files
chgrp -R <whatever group> gitrepo
chmod -R g+swX gitrepo
make sure new files are read/write for the group
- change the umask for all users to 002 (many machines have the default as 022)
alternative/additional theories
- make an alias when using root so git='su -m webuser -c git'
- add post-update hooks to set permissions everywhere
chmod -R g+rw . 2>/dev/null
- learn more about ACL on unix machines which go beyond the typical rwx stuff