开发者

Maintaining a patch set for different branches

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开发者_StackOverflow中文版 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?


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜