Reputation: 139
I'm currently looking for a way to "split" the content of an existing Git branch (let's say, dev
) within a git repository, to create two branches (let's say, dev-ui
and dev-backend
), each one containing half of the data of the original.
The use case here, is that I'd like to have two distinct branches for specific purposes (i.e. one for UI work, and the other for backend work, for example) that can both merge into the repository's main branch.
I've had a look at creating a couple of orphaned branches, each with half of the code from the original, but they don't share commit history therefore I'm unable to merge these into the main
branch in Github.
If anyone has any ideas how to accomplish anything similar, whether the exact functionality above, or something completely different but accomplishes a similar goal, I'm all ears! Thanks in advance :)
Upvotes: -1
Views: 81
Reputation: 2899
I think it is a better idea to create two new repositories for ui
and backend
and then add those as git submodules
to your main app
repository. This is the cleanest approach. You can read more about submodules
here. You can then "synchronise" the module in your parent application, and each branch, since it will be created on the submodule repo, will only have the files of either ui
or backend
.
Trying to create branches that have inherently different data is not doable, I think, since all branches, by design must share, the same data as the parent branch, otherwise, like you said, the merge will not work and forcing a merge will delete the files from the parent that were deleted in the branch you're trying to merge.
Upvotes: 1