Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

A way to automatically sync stable and develop branch in GitHub repo

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:

  • fix a bug -> should create a pull request for stable(we call it hotfix)
  • create a feature or fix a bug in new feature -> should create a pull request for develop(we call it feature)
  • when we want to release new version we merge feature in stable.

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?

like image 538
kharandziuk Avatar asked Nov 01 '22 13:11

kharandziuk


1 Answers

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.

like image 169
Nick McCurdy Avatar answered Nov 09 '22 03:11

Nick McCurdy