Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Integrating public git repository into private project (without submodules or subtree merge)

Tags:

git

What's the best approach to incorporating code from a public repository into a private project where the public code can't be constrained to a subdirectory? In my case, I'm working on a game and I'd like to use the beta branch of the engine (which is available as a git repository), but all my custom code needs to be under a subdirectory of the engine's code, so submodules won't do the trick. Since I'm working with a small team, I want to be able to push my changes up to our remote repository to share. I'd also like to be able to pull in changes from the engine's author, but I'm not worried about pushing any changes to the public repository.

The simplest approach is to just keep a separate folder with a clone of the engine's repository around, and occasionally update it and copy the files over (they're well organized, so this isn't as bad as it sounds.) I'd love to be able to do this with git, however.

like image 491
ken.dunnington Avatar asked Oct 08 '22 21:10

ken.dunnington


1 Answers

Clone the git repo, create a branch named upstream-beta (which you never work on) and you're done.

When you want to get the upstream's changes, switch to that branch, pull, switch back to master (or whatever branch you work on), cherry-pick or rebase off of upstream-beta to get that repos' changes.

like image 148
chelmertz Avatar answered Oct 12 '22 21:10

chelmertz