We have two servers - ServerA (bare repo) and ServerB (hosted project folder). Every time a developer pushes local changes to ServerA they should be automatically pushed to ServerB.
What I have tried so far: I created a post-receive script in bare_repo/hooks/. The script is:
#!/bin/bash
while read oldrev newrev ref
do
if [[ $ref =~ .*/master$ ]];
then
echo "Master ref received. Deploying master branch to production..."
git --work-tree=remoteaddress --git-dir=/volume1/_Repos/test.git checkout -f
else
echo "Ref $ref successfully received. Doing nothing: only the master branch may be deployed on this server."
fi
done
Where remoteaddress is something like IPServerB:/path/to/hosted_project_folder.
My entire approach:
hosted_project_folder already existed. Then on ServerA:
git clone --mirror IPServerB:/path/to/hosted_project_folder
git fetch --all
Add post-receive script in hooks.
On Client:
git clone IPServerA:/path/to/bare_repo
Add changes at Client and push it to ServerA:
git add -A
git commit -m "add something"
git push origin master
Where origin is IPServerA:path/to/bare_repo
At this point I get an error:
remote: fatal: Invalid path '/volume1/_Repos/test.git/IPServerB:C:': No such file or directory
However, if we use one server for bare repo and hosted project folder then it works.