Reputation: 40507
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?
Upvotes: 1
Views: 6248
Reputation: 2451
I had the same problem. I am developing and testing on a separate development server (devserver), while my IDE (PhpStorm) is on my Macbook. I am using ExpanDrive to mount the webroot of the devserver via SFTP (SSH) on my Mac. When I tried to use Git on my Mac I received errors about the SHA1 files and other things.
I have solved it this way:
I have moved the .git
dir from the mounted drive in /Volumes/devserver
to a location in my home dir on my Macbook. And after that I symlinked the old location to the new location of the .git
dir. I had to use ../../Users/jeroen/###
because otherwise the link was not correct.
Example to move and make the symlink:
cd /Volumes/devserver
mkdir -p /Users/$USER/Code/devserver
mv .git /Users/$USER/Code/devserver/.git
ln -s ../../Users/$USER/Code/devserver/.git ./git
git status
The first time you use the "git" command it might take a while, because Git is rebuilding some caches.
Upvotes: 0
Reputation: 1800
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.
Upvotes: 0
Reputation: 40507
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.
Upvotes: 0
Reputation: 16315
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).
Upvotes: 2