简体   繁体   English

已有拉取请求时如何发送对新文件的拉取请求

[英]How to send pull request for new file when already a pull request exists

I have this situation. 我有这种情况。 I forked a repo from github. 我从github分叉了一个仓库。 I made some changes in a separate branch locally. 我在本地的一个单独分支中进行了一些更改。 Then merged it with master. 然后与主人合并。 Then i pushed it to my github repo. 然后我将其推送到我的github仓库中。 I also send the pull request. 我也发送请求请求。

Somebody made changes in a file on the main repo. 有人在主存储库的文件中进行了更改。 I want to fetch it and make changes in that file. 我想获取它并在该文件中进行更改。 I want to send its pull request separately. 我想单独发送其拉取请求。

How do i start from my local repo ? 我如何从我的本地仓库开始?

I made some changes in a separate branch locally. 我在本地的一个单独分支中进行了一些更改。 Then merged it with master 然后与主人合并

Don't: you should make a pull request from the branch which isn't present in the upstream repo you have forked. 请勿:您应该从分支发出一个拉取请求,该请求在您已分叉的上游存储库中不存在。
That way, you can keep master always in sync with the master of the upstream (original) repo. 这样,您可以使master始终与上游(原始)存储库的master保持同步。

See " a couple of tips on pull requests " for more. 有关更多信息,请参见“ 有关拉取请求的几点提示 ”。

上游和叉子

That means: 这意味着:

I forked a repo from github. 我从github分叉了一个仓库。 I made some changes in a separate branch locally 我在本地的一个单独分支中进行了一些更改

Push that branch, and make your pull request from that branch (with a target: upstream repo/master ) 推送该分支,并从该分支发出拉取请求(目标为: upstream repo/master

You can then pull from upstream to update your master (which you never touch: you just add commits from the upstream repo to your local clone, and push master to your fork to keep it up-to-date). 然后,您可以从上游拉动以更新主服务器(您永远不会碰到:您只需将上游回购中的提交添加到本地克隆中,然后将主服务器推送到您的fork中以使其保持最新状态)。

Then you can rebase your local branch on top of the updated master, check that everything is still working, and push --force to your fork that branch. 然后,您可以将本地分支重新建立在更新后的master之上,检查一切是否仍在工作,然后将--force推入分支的分支。

The magic is: your existing pull request will automatically be updated with your new commits from that branch you just forced push. 妙处在于:您现有的拉取请求将自动用刚强行推送的该分支中的新提交进行更新。


In details: 详细说明:

cd /local/path/to/your/clone
git remote add upstream https://github.com/user/original_repo
git fetch upstream

git checkout master
# reset master to upstream master
git reset --hard upstream/master

git checkout yourBranch
git rebase master
# check that everything works

git push -f origin master
git push -f origin yourBranch
# Make your pull request from your branch in your fork on GitHub

Once that is done, future evolutions to your patch mean: 一旦完成,您补丁的未来发展将意味着:

# update master with upstream master new commits
git checkout master
git pull upstream master

# rebase your local branch
git checkout YourBranch
git rebase master
# check that everything still works

git push origin master
git push origin yourBranch
# your pull request will AUTOMATICALLY BE UPDATED!
# nothing to do on GitHub

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

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