Reputation: 1881
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?
Upvotes: 7
Views: 3122
Reputation: 3890
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.
Upvotes: 7
Reputation: 282
There is no such thing in git.
If you are really after git solution, I suggest creating a "common" branch and have all your branches merge from that.
Always commit changes to common code to the "common" branch and merge that to platform branches, so you will prevent conflicts and merging things you do no want (or you can cherry-pick.)
Also I think you could make the commons file read-only on platform branches to prevent modifying it without being slapped.
CONS: Tedious, but should work.
Alternatively, use different subdirectories for each platform and let your build system pull in the right files for each build.
CONS: You won't get merges as with git branches.
Upvotes: -1