Friday, April 29, 2011

Git commit permissions error when working on a remote host

I'm trying to get my website under version control. I work directly on the server with ExpanDrive, which uses MacFUSE to mount the SFTP connection as a local volume which I can access with the terminal and other local applications.

Anyway, everything goes smoothly until I try to commit, when I receive this message:

fatal: exec .git/hooks/pre-commit failed.

If I try to run the exec command manually, I see this:

-bash: /Volumes/1&1 Internet/website/.git/hooks/pre-commit: Permission denied
-bash: exec: /Volumes/1&1 Internet/website/.git/hooks/pre-commit: cannot execute: Unknown error: 0

I've tried using my SFTP client to give everything under the .git directory full (777) permissions, and still no luck. Does anyone know of anything else I could try?

From stackoverflow
  • By giving everything under the .git directory full (777) permissions, you have enabled all of the example scripts that ship with Git in .git/hooks, normally with their execute bits off. When you try to commit the now executable sample pre-commit script tries to run to format the commit as a patch.

    Unless this is what you are trying to do, I suggest you chmod /git/hooks/* to 644, so that the hook scripts do not execute.

    Edit -- Resetting the hook permissions gets you back the condition where you had the problem first. Next try the commit with the --no-verify flag, which is supposed to bypass the pre-commit hook (and also some minor checks on the commit message). This may be a workaround, but I still don't see why you had the initial problem. The code looks very straightforward -- I don't see how it could try to execute that hook if it's not enabled. If that fails in the same way, then I would think that the ExpanDrive/MacFuse system is not handling permissions properly (but that's pretty unlikely).

    Marc Charbonneau : Thanks for the advice, unfortunately I'm still seeing the error after trying this.
    Paul : I think my brain was already on the way to the airport when my fingers were still on the keyboard. Obviously resetting the permissions only gets you back to where you originally had the problem.
    Marc Charbonneau : Unfortunately I had trouble even with --no-verify, now I'm getting an error just adding files in a fresh repo. I'm giving up on this one.
  • I ended up setting up a local development environment on my laptop, I'm giving up on trying to use git through ExpanDrive. After spending some more time with it it seems like these tools just weren't meant to work together.

  • I believe recent versions of git use a different mechanism than permissions to enable hooks. So if you are using a recent version, you might remove everything from the .git/hooks directory (or move it somewhere else), and see if that is the problem.

0 comments:

Post a Comment