How to manage multiple similar but different projects with git?
Asked Answered
P

2

8

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?

Pazit answered 17/7, 2011 at 10:25 Comment(8)
do your projects share common code? if so, you can have three repositories: core, projectA and projectB. changes and fixes happen in core and get pulled to projectA and projectB. changes unique to either project happen in the project repositoryAustraloid
Could you explain why you cannot use submodules?Darnelldarner
@Australoid can't do that, because I need to control which change goes where as I charge for themPazit
@Darnelldarner I work with other people from the client side whom I don't want to see what I am doing on other projects, for obvious reasons.Pazit
@sanmai: you can still control which changes go where, just pull the appropriate parts of historyAustraloid
@Australoid I tried, everything becomes a mess because the projects are too different: some are really ancient, some are new, and so on. Not mentioning that my clients can modify their own projects code, then I have to pull their changes twice. It's a nightmare.Pazit
if they are too different, then they are not 'similar code base'. they probably have diverged too muchAustraloid
They're similar enough that I can copy specific changes from each other.Pazit
T
1

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.

Thermomotor answered 17/7, 2011 at 21:44 Comment(0)
D
5

The following are more like suggestions

Subtree merging

Stitching together repositories

I'm really interested also in this and I'll come with an update if I get to any definitive answer.

Darnelldarner answered 17/7, 2011 at 22:34 Comment(0)
T
1

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.

Thermomotor answered 17/7, 2011 at 21:44 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.