Pergunta

I'm hitting another wall in my quest to get better understanding of Git and the right web deployment workflow. I'm a novice when it comes to server related softwares and unix commands, so keep that in mind when answering. A bunch of questions have been asked on similar topics, but I'm not finding anything on specific push and merge to remote repositories with a post-receive hook.

I have 3 stages set for deployment.

Production (remote server I assume bare repository)
^
Staging (remote server bare repository)
^
Development (local machine)

I have Git up and running on my local and staging environments so far. I have a post-receive hook set up on my staging server. This seems to work great so far, but it doesn't seem that this hook will allow me to push branches that can be seen on the staging server. The staging server only serves the pages in the state of the master branch. This is probably expected behavior.

Should I be using this hook on the staging server? The only way I can seem to make changes go live is to first merge to the master on my local machine and then push that to staging. This doesn't seem right, because if the change needs adjusting. I would have to undo the merge on the local?

I'm pretty certain that the bare repository and post-receive hook will work great on the production server. Because it should really only have one state.

These may all be normal behaviors and my workflow may be incorrect. Any help on this or guidance is appreciated. I have searched this and I'm not finding any clear documentation.

Foi útil?

Solução

If you have no control over the Staging post-receive hook (i.e. Staging will always serve master, period), you can always push whatever branch you want to the master remote branch:

git push --force Staging my-funky-branch:master

Note that redefining the remote master branch like this will create problems for anyone downstream (anyone who might pull or fetch from) from Staging.

You could also create a special local branch to track the Staging master, and merge all changes to that branch.

git branch --set-upstream staging-master Staging/master
git checkout staging-master
git merge --no-ff my-funky-branch
git push

If you have control over the post-receive hook, you could use something like this to automatically serve the branch you pushed.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top