tags:

views:

65

answers:

1

I'm in the position of generating a series of documentation patches each of which applies to more than one branch. The project uses Git for version control.

The patches should apply cleanly on top of these branches as they are.

What is optimal workflow for applying the patches to multiple branches with minimal effort?

+1  A: 

New answer

You seem to be looking for git-cherry-pick. This command is used to grab a named commit and commit it to the current branch. The basic syntax is git cherry-pick <commit>; here's the man page.

However, you should avoid cherry-pick when possible, since it creates duplicate commits, and you'd really like to see them as merges. You should try to adopt a branch workflow that "merges upwards". From man gitworkflows:

Always commit your fixes to the oldest supported branch that require them. Then (periodically) merge the integration branches upwards into each other.

This gives a very controlled flow of fixes. If you notice that you have applied a fix to e.g. master that is also required in maint, you will need to cherry-pick it (using git-cherry-pick(1)) downwards. This will happen a few times and is nothing to worry about unless you do it very frequently.

In your case, you should be able to divide up your documentation updates into several classes, e.g. "featureA-documentation", each of which will be merged into one or more branches. You could easily write yourself a script to automate checking out the various branches and merging in appropriate topics.

Old answers

Look at the edit history if you're curious - these addressed how to get patches from multiple branches from the local repo into a remote one, with push or patch submission.

Jefromi
Actually, I do have push access, but this is a clone repo. When I say patch set, I actually mean patches committed to my local branches.
Robert Munteanu
I added a bit about the most common way to do this - you don't have branches with different names in the two repos, do you? Then you'd need to configure them to track the right branch (branch.<name>.remote and branch.<name>.merge) and use push tracking, I believe.
Jefromi
Hm, I think I'm a bit confusing at this time, let me try again. I'm going to clone a repo and maintain the same patches/commits for multiple branches. So documentation patches 1,2,3 apply to branches A and B. What I want is to apply these patches to both branches, e.g. specify that these commits should go to branch A and B. Assuming that I have them on branch A, how would I get them on branch B, besides `format-patch` and `apply`?
Robert Munteanu
Ah! Now I see what you're asking. I read the title and saw "different branches" and interpreted "more than branch" as "more than one branch has patches". More answer above soon!
Jefromi
Thanks for the patience, answers and editing.
Robert Munteanu
Sorry I read so carelessly the first time!
Jefromi