From the article, you have one main, bare repository called 'hub'. The 'prime' repository and the repository on your computer are clones of 'hub'.
In your situation, you have two 'prime' repositories: one is your staging area ('prime-staging') and one is your production area ('prime-production').
Using a combination of the hooks described in the article and the one described here (that takes a certain action depending on which branch is pushed), your 'prime-staging' or 'prime-production' repositories will be updated.
The 'hub repository should have two branches: master
(or staging
) associated with your staging site and production
associated with your production site. You would do all your work on master
, and push these changes to 'hub', allowing the git hook to update the staging repository. You would look at these changes in the live environment, making any changes needed on master
and pushing again to 'hub'. Once the staging site looks good, you would do:
git checkout production
git reset --hard master
git push origin production
Now, the git hook will see that the production branch has been updated and update your production site accordingly. (NB: assuming hub is just the nomenclature, it's standard to call your primary repository origin
)
So the setup I imagine on the server is:
mkdir -p /path/to/site.git
cd /path/to/site.git #// hub
git init --bare
cd /var/www/vhosts
git clone /path/to/site.git site.com #// prime-production
git clone /path/to/site.git staging.site.com #// prime-staging
You place the hooks in site.git
. When the staging
branch is updated, change into /var/www/vhosts/staging.site.com
and execute a git pull
. And do the same when the production
branch is updated for /var/www/vhosts/site.com
.