gitmultiple-repositories

How to manage multiple similar but different projects with git?


I have multiple different closed source projects based on a similar code base and every single day I need to copy changes and fixes from one to another and back.

As some of my projects are diverged too much to use git submodules and in others I don't want my clients mess with submodules and consequently peek into my work on other projects now I do that with git patch and git apply which is a tedious job.

I am about to consider a switch to git pull and git push between local repositories on my machine consequently using git cherry-pick and git merge to pick up needed changes, but if there is a better way?


Solution

  • Using git cherry-pick may do what you want. By having the other repository as a remote you can fetch from, you can still cherry-pick single commits. You don't have to create a branch of the remote either, just fetch in the changes and cherry-pick the sha1 of the commit you're wanting to port. When you push, it shouldn't push the other fetched references, as they're not on your current branch, just the cherry-picked commit is.