I am attempting to use git to deploy changes to a site on a locally hosted server. When I push the changes from my local directory to the dev server, the post-receive hook provides the feedback I would expect if it were working, but it doesn't actually change any files in the working tree.
Also, I am developing on a mac and the site is hosted on a windows server shared on the network and mounted to /Volumes/I$
Here is the hook script
#!/bin/bash
GIT_DIR=/Volumes/I$/intranet_dev
WORK_TREE=/Volumes/I$/intranetdev
while read oldrev newrev ref
do
if [[ $ref =~ .*/master$ ]];
then
echo "Master ref received. Deploying master branch to test server..."
mkdir -p $WORK_TREE
git --work-tree=$WORK_TREE --git-dir=$GIT_DIR checkout -f
echo "Git hooks deploy complete"
else
echo "Ref $ref successfully received. Doing nothing: only the master branch may be deployed on this server."
fi
done
The bare repository is located at a remote which I have labeled "test". When I issue the following command, I get the following output in my terminal...
computername:intranet username$ git push test master
Counting objects: 6, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (6/6), done.
Writing objects: 100% (6/6), 566 bytes | 0 bytes/s, done.
Total 6 (delta 5), reused 0 (delta 0)
remote: Master ref received. Deploying master branch to test server...
remote: Git hooks deploy complete
To /Volumes/I$/intranet_dev
1d9eb1f..f49b533 master -> master
This all looks as it should, but the changed files are not copied over.
You're checking out the current HEAD
. You sure that's attached to the master branch? Why rely on that? Try checking out master
instead.
Minor point, if [[ $ref = */master ]]
(or as long as we're being safe and all, if [[ $ref = refs/heads/master ]]
as @torek points out) is all you need there.