Pregunta

here is the situation: i want to use git to track a directory of preference files that are owned by root.

it would be nice if git commands that don't modify the files (like git status and git diff) can be run as the user (without sudo).

through the following steps, i've created a repo that seems to function in a reasonable manner:

sudo mkdir .git
sudo chmod <user>:<group> .git
git init
git add .
git commit -m "initial commit"

i can run git status and git diff as the user. git checkout ... and git reset ... fail as the user, but seem to run fine when prefixed with sudo.

this seems perfect: no sudo needed to get into the repo and take a look at what's gone on, but to change the tracked files requires an extra level of effort, as it should for system files.

the question is: will this cause me any problems with how git is reading and writing files inside the .git directory? will any commands i need sudo to run end up creating things inside .git with root permission that will then cause problems trying to run commands that don't modify the tracked files as the user?

thanks and advance for any answers.

No hay solución correcta

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top