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?

Mr_and_Mrs_D
  • 27,070
  • 30
  • 156
  • 325
sanmai
  • 23,569
  • 11
  • 54
  • 73
  • 2
    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 repository – knittl Jul 17 '11 at 10:30
  • Could you explain why you cannot use submodules? – celavek Jul 17 '11 at 10:50
  • @knittl can't do that, because I need to control which change goes where as I charge for them – sanmai Jul 17 '11 at 10:57
  • @celavek 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. – sanmai Jul 17 '11 at 11:04
  • @sanmai: you can still control which changes go where, just pull the appropriate parts of history – knittl Jul 17 '11 at 11:06
  • @knittl 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. – sanmai Jul 17 '11 at 11:11
  • if they are too different, then they are not 'similar code base'. they probably have diverged too much – knittl Jul 17 '11 at 11:19
  • 2
    They're similar enough that I can copy specific changes from each other. – sanmai Jul 17 '11 at 11:25

2 Answers2

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.

Community
  • 1
  • 1
celavek
  • 5,195
  • 5
  • 37
  • 68
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.

Corey Henderson
  • 6,661
  • 1
  • 35
  • 41