I have a project targeted to multiple platform. I have to change UI codes for different platform while keeping core classes same. To achieve this, I thought to make git branches for different platform.
Given the above scenario my requirement is, if I make changes in core classes it should be reflected in all git branches.
How to achieve this?
Or is there any other workflow to achieve the same?
Git can automatically merge the changes, so two people can even work on different parts of the same file and later merge those changes without losing each other's work!
Git offers a feature referred to as a worktree, and what it does is allow you to have multiple branches running at the same time. It does this by creating a new directory for you with a copy of your git repository that is synced between the two directories where they are stored.
Git Flow. The Git Flow is the most known workflow on this list. It was created by Vincent Driessen in 2010 and it is based in two main branches with infinite lifetime: master — this branch contains production code.
The Gitflow Workflow defines a strict branching model designed around the project release. This workflow doesn't add any new concepts or commands beyond what's required for the Feature Branch Workflow. Instead, it assigns very specific roles to different branches and defines how and when they should interact.
git rebase
You may handle your specific platform via git rebase
instead of git merge
. In this case you will be able to change core branch and than rebase other branches on it keeping platform specific modifications applied over core.
Make platform branches
git checkout master
git checkout -b platform1
git checkout master
git checkout -b platform2
Make core modifications
git checkout master
# make modification
git commit
Make platform modifications
git checkout platform2
# make modification
git commit
Import core changes in platforms
git checkout platform1
git rebase master
git checkout platform2
git rebase master
git merge
It is also possible to use git merge
with strategy
option as said in git merge manual.
git checkout platform2
git merge -s recursive -X ours master
This will always choose platform specific changes in case of conflicts.
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