简体   繁体   English

保持Git分支最新,同时等待它们合并到上游

[英]Keeping Git branches up to date while waiting for them to be merged into upstream

I forked a GitHub project, implemented a few features and fixed a few bugs in separate branches, sending pull requests for all of them. 我分叉了一个GitHub项目,实现了一些功能,并在不同的分支中修复了一些错误,为所有这些分支发送了拉取请求。

While waiting for them to be accepted into upstream, I want to use all these features and fixes. 在等待它们被接纳到上游时,我想使用所有这些功能和修复。 For that, I create a branch 'my-master', from 'upstream/master' and merge all changes from other branches which are not yet in upstream. 为此,我从'upstream / master'创建了一个分支'my-master',并合并了尚未在上游的其他分支的所有更改。 I also write a list of applied patches into the README.md. 我还在README.md中写了一个应用补丁列表。

When one of my patches goes to upstream, there is no reason to keep that branch any more, so I delete it. 当我的一个补丁进入上游时,没有理由再保留该分支,所以我将其删除。

It works, BUT, here there is a problem with such approach: 它有效,但是,这种方法存在问题:

From time to time, I need to rebase all my unaccepted branches, to keep them up to date. 有时,我需要重新调整我所有未接受的分支,以使它们保持最新状态。 After that, I have to recreate 'my-master' branch and update its README.md again. 之后,我必须重新创建'my-master'分支并再次更新其README.md。

Is there a way I can speed up or automate this? 有没有办法加速或自动化?

Please, don't advise me to try git-up . 请不要告诉我尝试git-up It is useful, but does a different thing. 它很有用,但做的却不一样。

One technique is to rebase your branch onto the upstream each time there is a release. 一种技术是每次释放时将分支重新分支到上游。 You may want to create a tag at the old branch tip, or a dated-versioned branch name so that you don't lose your old history after garbage collection. 您可能希望在旧分支提示或日期版本的分支名称上创建标记,以便在垃圾回收后不会丢失旧历史记录。

Or you may want to use the merging rebase script that msysgit uses https://github.com/msysgit/msysgit/blob/master/share/msysGit/merging-rebase.sh , which creates the impression of a continuous line of development (via the second parent) that is equivalent to the above rebasing processes. 或者你可能想使用msysgit使用的合并rebase脚本https://github.com/msysgit/msysgit/blob/master/share/msysGit/merging-rebase.sh ,这会产生持续发展的印象(通过第二个父母),相当于上述的变基过程。

In both cases you retain a set of commits that you were happy with should your rebase fixes (from conflicts) end up being problematic. 在这两种情况下,如果您的rebase修复(来自冲突)最终会出现问题,您会保留一组您满意的提交。

This covers two problems: 这包括两个问题:

  1. upstream is slow to update (relative to the speed you want/need) 上游更新缓慢(相对于您想要/需要的速度)
  2. upstream is targeted at a different 'platform' and you'll always need fixes 'on top' for your platform/purpose. 上游针对不同的“平台”,您将始终需要“顶部”修复,以满足您的平台/目的。

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

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