简体   繁体   English

如何检出远程分支,将其重新建立为本地主机,然后与本地主机合并?

[英]How to checkout a remote branch, rebase it to local master and then merge with local master?

A project of mine, on GitHub, has been receiving merge requests from another person, lately. 我在GitHub上的一个项目最近已经收到另一个人的合并请求。 This is awesome, but I am being forced to learn how to manage these requests when conflicts arise. 这太棒了,但是当发生冲突时,我被迫学习如何处理这些请求。 The first few merge requests could be automatically merged by GitHub, so I had to do nothing. 最初的几个合并请求可以由GitHub自动合并,因此我什么也不做。 The latest one has a conflict, because his changes were made and submitted on top of an older commit of mine. 最新的版本存在冲突,因为他的更改是在我的较早提交上进行并提交的。 I made changes to the repository after he had checked it out, so his is older than mine and cannot be automatically merged. 在他签出存储库后,我对其进行了更改,因此他的存储库比我的存储库大,因此无法自动合并。

I'm trying to resolve this by checking out his branch, rebase it to the current local master and then merge it into my local master. 我正在尝试通过签出他的分支来解决此问题,将其重新设置为当前的本地主机,然后将其合并到我的本地主机中。

So, I add his repository as a remote. 因此,我将他的存储库添加为远程存储库。 I then try to checkout his repository, but when I look at the code in his repository it does not reflect what I see of his code on GitHub. 然后,我尝试签出他的存储库,但是当我查看他的存储库中的代码时,它并不能反映我在GitHub上看到的代码。 I just see a clone of my own local master. 我只是看到我自己的本地主机的克隆。 Here's a pseudo-run-down of what I'm doing: 这是我在做什么的伪记录:

git remote add person git://path/to/his/repo.git
git checkout -b person/master
git fetch person

After that, I can see his branch when I run git branch -r . 之后,当我运行git branch -r时,我可以看到他的分支。 His branch is named person/master . 他的分支名为person/master I then try git checkout -b person/master . 然后,我尝试git checkout -b person/master I look at the code in his branch expecting to see his changed code, but I just see my own code. 我查看了他分支中的代码,希望看到他已更改的代码,但我只是看到自己的代码。 When I look at his person/master branch on his fork on his Github page, I see changes he has made that are not being reflected in my checkout. 当我在Github页面上查看他的叉子上的person/master分支时,我看到他所做的更改未反映在我的结帐中。

What am I doing wrong? 我究竟做错了什么?

git remote add person git://path/to/his/repo.git
git checkout -b person/master
git fetch person

I would rather fetch first, then checkout: 我宁愿先获取,然后结帐:

git remote add person git://path/to/his/repo.git
git fetch person
git checkout -b person/master

But one of the idea behind pull requests is that they should be applied automatically... or "put on hold" ;) 但是请求请求背后的想法之一是,它们应该自动应用...或“搁置”;)
In other words, the contributors ought to do the work for you, then submit an updated pull request for you to apply. 换句话说,贡献者应该为您完成工作,然后提交更新的请求请求以供您申请。

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

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