简体   繁体   English

用于维护项目扩展分支的Git工作流程?

[英]Git workflow for maintaining an project extension fork?

We've forked an OSS project on GitHub and are adding some custom extensions to it. 我们在GitHub上分叉了一个OSS项目,并为它添加了一些自定义扩展。 We'll want to send some of the changes we make back to the original project (bug fixes and the like) but other changes are feature extensions that the original project maintainers aren't interested in at the moment. 我们希望将我们做出的一些更改发送回原始项目(错误修复等),但其他更改是原始项目维护者目前不感兴趣的功能扩展。 I'm trying to figure out the best workflow for managing this situation. 我正在努力找出管理这种情况的最佳工作流程。

I want our master branch to contain the sum of (commits from the original project) + (our bug fixes for contribution) + (our custom extensions). 我希望我们的主分支包含(来自原始项目的提交)+(我们的贡献的错误修复)+(我们的自定义扩展)的总和。 I imagine we'll want a branch-per-feature model so that we can keep bug fixes separate from custom extensions. 我想我们需要一个按功能分支的模型,以便我们可以将错误修复与自定义扩展分开。 We can start custom extension branches from our master branch, but I guess we'll also want to maintain a local "origin" branch or something that tracks the original project so that we can start bugfix branches from there that aren't polluted with our custom stuff. 我们可以从我们的主分支启动自定义扩展分支,但我想我们也想要维护一个本地“origin”分支或者跟踪原始项目的东西,以便我们可以从那里启动没有被我们的污染的bugfix分支。定制的东西。 Or something. 或者其他的东西。

Can anyone suggest the best way to structure this workflow such that all the various commits go where they're supposed to go and none go where they're not supposed to go? 任何人都可以建议最好的方法来构建这个工作流程,以便所有各种提交都去他们应该去的地方,没有人去他们不应该去的地方?

It sounds to me like you have already answered your own question. 听起来像你已经回答了自己的问题。 Create a branch called "vanilla" or something which tracks upstream's master branch, and have a "master" branch which contains your custom extensions. 创建一个名为“vanilla”的分支或跟踪上游主分支的东西,并有一个包含自定义扩展的“主”分支。 Create branches for each thing you do. 为你做的每件事创建分支。 For bugfixes, start them off of "vanilla". 对于错误修正,请从“香草”开始。 For your own stuff, start them off of master. 对于你自己的东西,从主人开始。 Every once in a while, merge vanilla into master. 每隔一段时间,将香草合并为主人。 To get the bugfixes into your custom extensions branch, you could merge their branches into master directly, or just wait for upstream to accept your bugfix pull requests, and then the next merge from vanilla to master would contain the bugfixes. 要将错误修正带到您的自定义扩展分支中,您可以直接将它们的分支合并到主服务器中,或者只是等待上游接受您的错误修复请求,然后从vanilla到master的下一个合并将包含错误修正。 This seems like a very normal workflow. 这似乎是一个非常正常的工作流程。

What you want to setup is a long term fork , to do this as you already figured out the solution could be setting up a special branch linked with the original "vanilla" project and have a master branch where you maintain your custom working copy. 您要设置的是一个长期的分支 ,为此您已经发现解决方案可能是设置一个与原始“vanilla”项目链接的特殊分支,并有一个主分支,您可以在其中维护自定义工作副本。

The only thing that you have to keep in mind (from my point of view) is that you shouldn't merge the two branch when you want to synch changes, but in this case ( When Branches Diverge ) there is the handy Git Cherry-Pick command that lets you take a single commit from one branch and apply it to another , this could be particularly useful in the case of maintaining a fork because you can easily exchange single commit from one branch to another ... 你需要记住的唯一一件事(从我的角度来看)是你想要同步变化时不应该合并两个分支,但在这种情况下( 当分支发散时 )有方便的Git Cherry-选择命令,允许您从一个分支进行单个提交并将其应用到另一个分支 ,这在维护分支的情况下特别有用,因为您可以轻松地将单个提交从一个分支交换到另一个分支...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM