We are currently a team of 3 developers working in a project using gitlab.com
We have two servers, one for production and one for testing, both running on different droplets.
After we're done with our changes, we push to the testing server where we have this Git post-receive hook (it's a bare repository):
#!/bin/sh
git --work-tree=/var/www/domain.com --git-dir=/var/repo/site.git checkout -f
We use a branch named 'testing' (which is checked out in the testing server), so everything works fine. After everything is OK, we merge that into master and then push to production. The issue here is that there might be sometimes where we need to create a branch to fix a bug in production but we don't want to upload the work in progress in our testing branch, and we also want to test out this hotfix branch in our testing server.
That's why I figured we could just checkout the incoming branch in the testing server, so everyone can test their code on a live server without always having to have the testing branch checked out. Can this be done? I tried googling the git environment var for the incoming branch which would make it trivial from there but didn't get any luck. I know we all could just push and the manually checkout the branch in the testing server but that solution is not appealing. It would be more efficient to do just with git push and let the server handle the rest!
This is definitely not the best way for deployment using Git, so I'm all ears for suggestions!