Davi Bogo
Davi Bogo

Reputation: 149

How to work with more than one version of the same application at the same time in git?

I have an application that is going to be used for a lot of clients, currently we have two versions of it, one is the core version, the other will be used by one of my client. For now we have two branches (master, client_1) and they're similar, but different.

My problem is that if I correct something just for client_1, it's easy, I just have to commit in that branch. But if I correct something for both, I don't now how to "merge" it, because if I merge my git tries to merge everything, not just my correction.

Now, imagine that my application expands to 15 clients, each one has something different, small changes, but it's different. How do I control this kind of problems?

Upvotes: 1

Views: 341

Answers (2)

Gem Taylor
Gem Taylor

Reputation: 5635

If you can arrange it client-specific "cosmetics" changes should be done on the client-specific branch, or on fix branches branched from the client branch.

The philosophy is that these changes are never merged back onto the main branch.

In a perfect world all changes on the main branch should be safe to merge TO all client product branches, but you might want an additional test phase before accepting them.

If a change is made and checked in to the client branch that is wanted for main or specific other clients then cherry-pick is the way.

If an unwanted client edit is found on the main then either you can roll main back, or apply another change to reverse it. Then cherry-pick it to where it should be if necessary.

Git cherry -v will show you what changes are available to be copied between the branches, while git cherry-pick will let you select a specific change set, or a number of related changes to merge over in isolation.

Note that your default regular flows should not involve cherry-picks, because the two instances of the change will have different hashes.

Upvotes: 1

eftshift0
eftshift0

Reputation: 30297

I think what you are looking for is "cherry-pick". That small change, you commit it on the main branch... then on the client branch, you cherry-pick the revision.

Upvotes: 1

Related Questions