1

I am trying to find a good solution using git to manage a big project in a flexible way for different platforms, clients, features...

As a simple example (in order to understand what it's my problem, but in reality it will be more complex) suppose I have my master branch were I add all the common source. From it I create branches for different operating systems such as win (for Windows), gnu (for GNU), etc and branches for any feature that a client can demand or not (to make it easy, I call them client_a and client_b).

* client_b
| * client_a
|/
| * gnu
|/
| * win
|/
* master

This way if one client demand for an application running on Windows with the features I did in client_b branch, I could create a branch (winB) from the branch 'win' as:

git checkout -b winB
git merge client_b

This new branch will contain all features included in client_b and will be ready to generate a Win application, at least this is my intention. The problem is that doing this way, if I want to fix a bug or add more code in branch client_b and I want that winB and all other branches depending on client_b gets also this changes I have to go one by one doing something like this (this is the concrete case for winB)

git rebase client_b
git merge win

Note that this is even worst when I have to add something new in master where all is depending on! So, my question is, having this scenario, how would you do to manage these branches and have easily the results of the merges (winB in our case) up-to-date without going one by one of these branches rebasing and merging again? Proposals for other better scenarios to achieve this are welcome as well.

Thanks in advance!

Charlie
  • 152
  • 1
  • 12

1 Answers1

0

You've got a few options.

Firstly, if the client code branches are used anywhere else (someone else is coding against them) then you should not use rebase. rebase rewrites the history, including the SHA1s and can cause a lot of grief if other people are relying on the history.

The first option is to create patches of the feature and apply that on the branches you want the feature in.

The second is to cherry pick the commits into the branches where you want them.

The third is to simply merge the changes in, altough this won't work if some of your branches have diverged from master to enable a local feature (e.g. for Windows).

I would opt for patch or cherry pick and write a script to enable this process to be automated for the specific branche or groups of branches.

E.g:

apply_patches_for_win windows-feature.patch

or

cherry_pick_for_win commit_SHA1

You could also write a script to rebase the branches, if rebase is still the best option.

Richard Hulse
  • 10,383
  • 2
  • 33
  • 37