0

My team is working on a Unity project with a large 3rd party SDK. There is a new preview SDK that allows us to target a new device that only two of us have access to. I created a new branch 'new_sdk' and integrated that SDK there and got it working with the new device.

Now moving forward I want to keep the original branch with the old SDK and the new_sdk branch for the new SDK, but otherwise merge changes outside of the SDK between the branches. Other developers on the team only have access to the old device so we really have to do this.

One solution is to exclude the library folders from source control via .gitignore and then manually copy them over when you want to switch branches. But that isn't nice.

I started looking into .gitattributes and merge drivers from this article: https://medium.com/@porteneuve/how-to-make-git-preserve-specific-files-while-merging-18c92343826b#.m58m7t1qp But it seems complicated and I couldn't get it to work when I followed the steps in the article on a test repository.

Is there a way to make merge drivers work and do what I want?

Is there a better approach?

1

2 Answers 2

1

You should make your SDK folder a submodule of your main project repository.

Basically, you create a new repository and push your SDK there, only the folder, no project folders.

Then you go into your main project at the Git level and use submodule commands:

https://git-scm.com/book/en/v2/Git-Tools-Submodules

at that point, you will add the SDK but the main project will not track it. Pushing to your main project repository and the SDK will show as grey folder and is basically a pointer to the other repository.

Now you can push your main project and your SDK independently.

1
  • I will give this a try in the morning and hopefully come back and mark this as the accepted answer. Thanks.
    – ThisGuy
    Commented Jul 15, 2016 at 7:24
0

git submodules are one of the options to achieve what you are looking for. I have written an extensive document and an example project on github at https://github.com/abdes/submodule-docker-dev-workflow that can help you get started and also understand the common scenarios related to git submodules in the development workflow.

The great thing with submodules is that the container repo and the submodule repo are completely independent. You can freely branch your container project without having to branch the submodules.

Not the answer you're looking for? Browse other questions tagged or ask your own question.