给定拉数时如何应用git补丁
我从git下载了一个代码库的主干版本,并且有构build错误。 现在补丁已经可用了,我收到了一封电子邮件:
请参阅https://github.com/JustinTulloss/zeromq.node/pull/47获得补丁
我是git的新手,所以我不太确定如何处理这个“补丁”,因为这个页面看起来更像是一个讨论主题。
有谁知道我可以如何获得/应用这个补丁到我的本地克隆git仓库?
保存修补程序的地方。 如果你使用linux,你可以使用curl:
curl -L https://github.com/JustinTulloss/zeromq.node/pull/47.patch > /tmp/47.patch  使用git apply来应用补丁。 你可以看看这个补丁是否会用check选项干净地应用。 转到你的git目录并运行: 
 git apply --check /tmp/47.patch 
如果看起来您想要应用修补程序,请移除检查选项
 git apply /tmp/47.patch 
 只需在最后添加一个.patch即可获得该补丁: 
https://github.com/JustinTulloss/zeromq.node/pull/47.patch
你可以做如下的事情:
 $ git checkout master $ curl http://github.com/JustinTulloss/zeromq.node/pull/47.patch | git am $ git push origin master 
规则似乎最近改变了。
 以前我们拿了一个PR,在最后添加一个.patch来获得补丁 
 http://github.com/[group]/[project]/pull/30583.patch 
但现在链接redirect(301)
 https://patch-diff.githubusercontent.com/raw/[group]/[project]/pull/30583.patch 
 所以如果你使用curl ,你可以使用git apply命令从Pull Request中应用一个git补丁 
 curl https://patch-diff.githubusercontent.com/raw/[group]/[project]/pull/30583.patch | git apply 
 如果现在补丁不适合你,请使用git apply -R命令来回滚更改。 
 git fetch -q origin +refs/pull/47/merge: git checkout -qf FETCH_HEAD 
 要让git下载请求47并将其修补到本地的mylocalbranch ,请运行: 
 git checkout -b mylocalbranch git pull origin pull/47/head 
如果拉取请求不在原始仓库上,请运行
 git remote add patchremote https://github.com/JustinTulloss/zeromq.node git pull patchremote pull/47/head