On my server, I have a git repository covering a to-be-web-readable directory. The contents of this particular user's
www directory will be readable and writable by that user, but I want the
.git directory to be owned by root.
Is there any way to make the .git directory sufficiently readable that the non-root user can checkout files as a simple means of reverting? Adding and committing aren't permitted (only the admin actually marks changes as "accepted", which can then result in them being promoted from staging), but it should in theory be possible for an unprivileged user to read from
.git and change files in
www. Commands like
git log and
git show have no trouble in this setup, but attempting a checkout fails:
$ git checkout www/some-file-name fatal: Unable to create '/REDACTED/PATH/.git/index.lock': Permission denied
Can I ask git to not lock the index? Can I somehow permit the index to be locked without opening too much else? (Obviously I can't make the
.git directory writable as that would forfeit all protection.)
NOTE: It is possible to work around this for a single file at a time:
$ git show HEAD:www/some-file-name >www/some-file-name
So it's clearly not a fundamental limitation. Maybe it's just that
git checkout assumes it's doing a branch switch? It is the most convenient way to manage wildcards and directory trees, though.
EDIT: This is not talking about a branch switch. I want to be able to use
git checkout to check out a single file. That's why the obvious answer is not applicable here.