I have one master branch where i am pushing my latest development.
Now at some point, I do release and create new branch called release1 from master branch.
Now i am doing new development on master branch
Meantime other team also perform some bug fixes on release1 branch.
Now time come for release2. Here i need to include bug fixes done on release1 to the updated master branch and then fork release2 branch.
New release2 branch should have all bug fixes done on release1 branch + latest development occurs after release1 on master branch.
What are the different possible workflow here.And based on that how to play with git merge and git rebase and git cherry-pick command here?
Solution which I prefer is as below.
master -> release1
master will have its own further development,
suppose some bug in release1 branch then one should create hotfix branch from release1 branch and after fixing bug in hotfix branch, just merge it into release1 branch and rebase hotfix with master branch to maintain history, once rebased with master branch merge hotfix in master branch so bug fixing will be in both master and release1 branch
now suppose it's time to have release2, you just need to create release2 branch from master branch because all the bugs are already fixed in master branch as well as all the new developments are in master branch.
Master
commit1
commit2 -> release1
commit3
commit4
git checkout release1
git checkout -b hotfix
Hotfix
commit2
bugfix1
Merge hotfix with release1 will become
git checkout release1
git merge hotfix
Release1
Commit1
commit2
butfix1
Rebase hotfix with master it will rewrite your history
git checkout hotfix
git rebase master
Hotfix
commit1
commit2
commit3
commit4
bugfix1
after that merge hotfix branch to master branch
git checkout master
git merge hotfix
Master
commit1
commit2
commit3
commit4
bugfix1
git branch -d hotfix
git push -d origin hotfix
don't forgot to delete hotfix because we are already done with that branch there is no more requirement of that branch once merged. you can also change names of hotfix branch to the jira ticket id or bug id if logged somewhere.
now creating release2 from master which is already have bug fixed in it.
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