如何在 git 中合并别人项目的拉取请求?
我在我的计算机上克隆了这个存储库: https://github.com/derobins/wmd.git
有几个错误不过,看起来另一个用户已经修复了它们并发出了“拉取请求”(我假设这些是提交更改的请求?)
是否可以将这些更改合并到我的本地版本中?
编辑:需要明确的是,这不是我的存储库。我正在使用 derobins 的 WMD 编辑器,但它有几个错误,这些拉取请求声称要修复这些错误。我已经在 Ubuntu 上克隆了该存储库(而不是在 github 中),并希望在可能的情况下合并这些更改。
I cloned this repo on my computer: https://github.com/derobins/wmd.git
There are several bugs with it though, and it looks like another user has fixed them and issued "Pull requests" (I assume these are requests for their changes to be committed?)
Is it possible to merge those changes into my local version?
EDIT: just to be clear, this is not my repository. I am using the WMD editor from derobins, but it has several bugs which those pull requests purport to fix. I have cloned the repo on Ubuntu (not in github) and was hoping to merge those changes in if possible.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
(GitHub 有关于如何处理拉取请求的非常详尽的文档。 )
本质上,您需要为发出拉取请求的人的存储库添加一个远程,例如:
...然后将他们的更改提取到远程跟踪分支中:
...这样现在您就拥有了来自的所有提交该人的 GitHub 存储库位于您的上游存储库克隆中。如果您查看该拉取请求中的其他提交,您可以:
git merge 75708aeab5
gitcherry-pick 2142db89
, gitcherry-pick 75708aeab5另一种方法是克隆发出拉取请求的贡献者的存储库,如果除了这些修复之外是相同的。
(GitHub has very thorough documentation on how to deal with pull requests.)
Essentially, you'll want to add a remote for the repository of the person who made the pull requests, e.g.:
... then fetch their changes into remote-tracking branches:
... so that now you have all the commits from that person's GitHub repository in your clone of the upstream repository. If you look at the additional commits within that pull request you could:
git merge 75708aeab5
git cherry-pick 2142db89
,git cherry-pick 75708aeab5
git checkout -b fix-for-issue3 75708aeab5
An alternative is to just clone the repository of the contributor who made the pull requests instead, if that's the same but for those fixes.
接受的答案建议为发出拉取请求的人的存储库克隆或添加远程。另一种更干净、更简单的方法是使用此命令
例如,在撰写本文时, ghi 有三个尚未合并的开放拉取请求。这就是我将它们合并到我的本地存储库中所做的事情。
请注意,两个拉取请求都是从 master 发送的,这就是我从他们的
master
分支拉取的原因。这样,其他存储库就不会添加到您的遥控器中,您也不必在本地挑选或克隆它们。
The accepted answer suggests to clone or add remote for the repository of the person who made the pull request. Another cleaner and simpler way is to use this command
For example, at the time of writing, ghi has three open pull requests that haven't been merged yet. This is what I did to merge them into my local repo.
Note that both pull requests were sent from master that is why I pulled from their
master
branch.This way, other repositories do not get added to your remotes, neither you have to cherry pick or clone them locally.