hey i'm developing react native application with different source some library are works in android and some working in ios i want to install library and write some codes just for android that ios not using it i knew i cal split codes via Platform.OS but i just want have different branches one branch for codes that share for android and ios project second branch for the codes that only writes for android third branch for the codes that only writes for ios
i'm new to git and reading documentation and not found anything thats help me to do this the way i found is copy paste code and push to git for each branch but its not the true way to handle this
CodePudding user response:
I would recommend a different approach by using git submodules. It requires a little extra learning but it is worth it.
Basically, each submodule is a repository of its own that is embedded within another repository.
So for example, if I were you I would do the following:
- Define three repositories: 'Android code' repository, 'iOS code' repository and 'Mutual Code' repository.
- I would then embed the 'Mutual Code' repository as a submodule into both the 'Android code' and 'iOS code' repositories.
- Now whatever you develop in the 'Mutual Code' repository can be easily updated within each of the other repositories.
I hope this helps.