In our project we use Fork & pull model when everybody have a form of a main repo and create pull request when finish task. This workflow is good enough when you have only one branch in main repo, but now we have to branches. There are "stable" branch for production code and "develop" for new features. Now our workflow looks like this:
But now we have a problem, when somebody creates a hotfix, he should merge this pull request to both stable and develop branches. This is not a big problem, but it is boring.
Is there a way to automate this process of syncing stable and develop branch? maybe some kind of hook or something another?
In my opinion, you should manually merge master
into develop
whenever a pull request is merged into master
, since there may be merge conflicts when merging the changes into develop
. As a result, it would be harder to automate this, since you would still have to manage conflicts manually if there were any.
However, if you wanted to automate this, you could have a simple script containing the code below. Simply run it after a pull request is merged into master
:
git checkout master
git pull
git checkout develop
git merge master # this step might require manual attention!
git push
git checkout master
If you want to automate this so it happens whenever master
is pushed to with server side hooks, see this article. Note that this will only work on servers you have direct access to, so you unfortunately can't use this with GitHub.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With