doing clean git pull-request to upstream

浪子不回头ぞ 提交于 2019-12-20 03:47:13

问题


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?


回答1:


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


来源:https://stackoverflow.com/questions/17600227/doing-clean-git-pull-request-to-upstream

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!