向上游做干净的git pull-request [英] doing clean git pull-request to upstream

查看:111
本文介绍了向上游做干净的git pull-request的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我克隆了一个回购(确保将原始回购标记为 upstream )并采用了gitflow方式:创建开发 code>分支,从中创建并返回所有新功能。从开发的每一次推动< Master 的定义都是一个版本,意思是 master 始终可部署。我很喜欢这个设置。



现在有时候除了这个流程之外,我可能想回到上游我保留在单独功能中的某些功能-branches。然而,由于从开发HEAD 开发创建的功能分支可能已经将其他功能分支合并回到,这会产生一个问题:


  • 将特定的特性分支合并回我自己的 develop 很好

  • 但我不确定如何从特性分支。即:在我开始当前<$之前,没有将之前的特性分支合并到 develop 中的所有代码更改c $ c>功能分支。我希望这是有道理的。



我很确定 rebasing doesn'因为这只会使用上游在此期间发生的提交来更新我的本地功能分支。它无助于使用从 develop 的继承代码更改清除本地功能分支。



那么,该怎么做? 在这种情况下,要从要贡献的分支的HEAD(位于上游存储库)中创建新的本地功能分支。然后检出这个分支并执行你想贡献的功能(提交范围来自你本地的开发人员 / em>分支)。



之后,您可以发布新的功能分支,您可以从中提交干净的拉取请求。


  1. 如何挑选多个提交


I've cloned a repo (made sure to mark the original repo as upstream) and went the gitflow way: create a develop branch from which all new features are created and commited back to. Every push to Master from develop is by definition a release, meaning master is always deployable. I like this setup a lot.

Now sometimes aside from this flow I may want to contribute back to upstream some feature that I keep in separate feature-branches. However since a feature-branch is created from develop HEAD and develop may have already had other feature-branches merged back into, this gives a problem:

  • merging the specific feature branch back into my own develop is ok
  • but I'm not sure how to do a clean pullrequest from this feature branch. I.e: without all the code-changes of previous feature branches that were merged into develop before I started the current feature branch. I hope this makes sense.

I'm pretty sure rebasing doesn't help, since this only updates my local feature branch with commits of upstream that happened in the meantime. It doesn't help to 'clean' the local feature branch with inherited code changes from develop.

So, how to do this?

解决方案

What I would do in this case is to create a new local feature branch from the HEAD of the branch you want to contribute to (which would be in the upstream repository). Then checkout this branch and git cherry-pick the commit range [1] that implements the feature you want to contribute (the commit range will come from your local developer branch).

After that, you can publish your new feature branch and you can submit a clean pull-request from it.

  1. How to cherry-pick multiple commits

这篇关于向上游做干净的git pull-request的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆