Reputation: 1508
When I am trying to run git commit -m 'message here'
I am getting following error.
fatal: cannot exec '.git/hooks/prepare-commit-msg': Permission denied
This issue started after when I created a new partition on my ubuntu and cloned the repo in it.
Upvotes: 4
Views: 14197
Reputation: 7810
I was able to resolve this:
Run the following command to check the file’s permissions:
ls -l .git/hooks/prepare-commit-msg
If the file is owned by a different user, you can change the ownership
sudo chown $(whoami) .git/hooks/prepare-commit-msg
Upvotes: 0
Reputation: 109
For me I was getting the error fatal: cannot exec '.git/hooks/pre-push': Permission denied
.
Applying Andreas's answer to this error message, I tried $ chmod +x .git/hooks/pre-push
, and that fixed it. The subsequent commit
and push
commands went through successfully.
Apparently such fatal: cannot exec ... : Permission denied
errors involving both git hooks can be resolved in the same way.
Upvotes: 0
Reputation: 31
For me, chmod +x
for those git hooks did not help and I had to remove the file (move it to {filename}.bak
).
I suppose this isn't a great solution, though.
Upvotes: 1
Reputation: 47099
You'll need to make your file executable, the below code snippet will make the file executable for the owner, the group and the world:
$ chmod +x .git/hooks/prepare-commit-msg
Upvotes: 9