我从 git 下载了一个主干版本的代码库,但存在构建错误。Aparently 一个补丁现在可用,我收到了一封电子邮件:
补丁见 https://github.com/JustinTulloss/zeromq.node/pull/47
我是 git 新手,所以我不太确定如何处理这个“补丁”,特别是因为该页面看起来更像是一个讨论线程。
有谁知道我如何获取/将此补丁应用到我本地克隆的 git 存储库?
我从 git 下载了一个主干版本的代码库,但存在构建错误。Aparently 一个补丁现在可用,我收到了一封电子邮件:
补丁见 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
但现在链接重定向(301)到
https://patch-diff.githubusercontent.com/raw/[group]/[project]/pull/30583.patch
因此,如果您使用curl
,您可以使用命令管道git apply
从拉取请求中应用 git 补丁
curl https://patch-diff.githubusercontent.com/raw/[group]/[project]/pull/30583.patch | git apply
如果补丁现在不适合您,请使用git apply -R
命令回滚更改。
要让 git 下载 pull request 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
git fetch -q origin +refs/pull/47/merge:
git checkout -qf FETCH_HEAD