I want to create an automatic staging branch creation process. When a user will push his changes to the git server, it should check the target branch - if the branch is a production branch it should instead push to a staging branch. (Later, a continuous integration process will start which will take care of pushing/merging the changes back into the production branch).
I have tried using git-hooks but I feel I am missing something. None of the git-hooks let me actually modify or manipulate the underlying git process and change the target branch, so I tried instead to use git-hooks to push to a production branch and then stop the rest of the process - but this causes the user to get a failure message and that is unwanted.
So I need a solution that will be:
- Seamless: Users won't know this is happening, as far as they know they are pushing their changes directly into their targeted branch and they get no error codes or confusing messages.
- Harmless: Not modify the targeted branch in any way.
- Magic: Silently create or update the staging branch associated with the target branch.
- Invisible: Should be server-side hook (such as update or pre-receive) so that users don't need to maintain their own hooks.
I previously asked this question, but it turned out to not be exactly what I wanted. So I created a new question with more clarification.
I am expecting answers to provide me with that "Aha!" realization of what I am missing. I have seen this process in action before and I know it's possible, I am just missing something. What I would really like to know is if its possible to modify the underlying git process with hooks, or to "hijack" the hooks return code so that it shows the user that everything went okay even though I stopped and change the process. Or perhaps another solution all together.
edit:
I myself am looking for a solution, and found something about Triangular Workflows which seems like it might be exactly what I want. But I can't figure out how to synchronize them automatically, it seems like every good solution requires some manual input somewhere along the line. Though I am certain that I have seen this setup working before and without the need to run any preparation scripts on the client side, and that the staging process was automagical.