I'm trying to get a git post-receive hook working on Windows.
I'm using Git 1.7.9 (Msysgit) and have a repo locally and a bare repo on a remote server. I can fetch, commit, push etc. I've set up a post-receive hook that should checkout the files into a working folder (part of the deployment process) but it doesn't seem to work.
Here's what I do:
- Change a file, stage and commit it
- Push to remote server - successfully
- Expect to see the echo - don't see the echo
- Check working folder on server - latest files are not there
- Log onto the server and run the hook script manually - latest files are checkout out into the working folder.
I changed the hook so it does nothing except echo a message and I've read that I should see this in my console after pushing. But this is not being displayed so I can only assume the hook is not being fired off.
I'm pushing over HTTP with git dot aspx on the server handling the request and pusing via the gui locally. After that failed I tried Bonobo and the hook doesn't work when pushing via the gui or a bash console.
I'm assuming someone has this working somewhere but after two days of searching all I have found are solutions that don't help or people with the same problem that has gone unanswered.
(I'm a git newbie btw).
Cheers.
Update
I'm starting to think it may be to do with permissions - but Unix permissions, rather than NTFS. When @eis mentioned permissions I had assumed NTFS. But after more digging it seems that Git on Windows still checks for Unix file perms.
So I suspect the issue is that the post-receive file is not executable as when I do a ls -o
it's -rw-r--r-- (644 I believe). If I try and change this through bash and chmod 777 post-receive
then do ls -o
the permissions are the same.
The strange this is that as soon as I edited post-receive (with notepad++) the execute bit gets removed. (my test script that ends in .bat does retain its execute bits though...)
BTW, the user I'm logged on as is the owner of the files (according to ls -o
) and yet I can't set the permissions.
Starting to get really confused now. Am I missing something really obvious?
Update 2
Neither chmod 777 post-receive
nor chmod a+x post-receive
work. I took a new, clean post-receive file, uploaded it the to the server and checked the permissions and it had execute. If I rename the file (to remove sample) in Windows then execute is removed. If I do it in bash with mv
execute is retained.
But, whenever I edit the file (in Windows or in bash with vi) then execute gets removed.
So, the problem now is why does it remove the execute bits when I edit the file?
Hopefully this is the final hurdle and the cause of it not executing...