Hi, I would like to use Git Hooks to push the changes to a production server.
I already configured a pre-receive and post-receive hooks and it is working, but I need to push to different locations depending on the branch that I am working on.
I think that I need to access the $GIT_PUSH_OPTION_COUNT and $GIT_PUSH_OPTION_X variables, but they are always empty in the pre-receive and post-receive hooks.
Can someone point me to the right direction on this?
Below is my post-receive hook. The master branch is hardcoded, but I need it to be dynamic.
#!/bin/sh SERVER="remoteipaddress" PROJECT="projectname" PROJECT_FOLDER="/var/www/clients/client0/web1/web" USERNAME=web1 USERGROUP=client0 echo "starting post-receive" git remote add origin [email protected]$SERVER:/var/repo/$PROJECT.git git push origin master ssh [email protected]$SERVER PROJECT=$PROJECT PROJECT_FOLDER=$PROJECT_FOLDER USERNAME=$USERNAME USERGROUP=$USERGROUP 'bash -s' <<'ENDSSH' echo "connected"; cd $PROJECT_FOLDER echo "updating project" git reset --hard git pull origin master chown -Rf $USERNAME:$USERGROUP . ENDSSH echo "done post-receive"