git - 将 github 提交/pull 请求作为补丁应用

标签 git github pull-request git-patch

如何应用来自github的补丁?

我尝试编译 minisat ,但我在使用 clang 进行编译时遇到了两个问题。

第一个问题已在 this github commit 中解决,它是从原始 github fork 出来的。由于变化很小,我可以轻松地修补代码以手动工作。

第二个问题在这个 github ( https://github.com/niklasso/minisat/pull/17 ) 中解决了,但是补丁没有应用到原始源。我可以通过复制修改后的文件来手动更新代码,但如果我能将这个补丁 pull 到我的本地目录中会更好。有可能用github做到这一点吗?如果可以,怎么做?

最佳答案

github 为个人提交和 pull 请求提供了补丁(虽然我找不到这方面的文档)。

您可以通过简单地将 .patch 附加到原始 url 的末尾来生成补丁 url。

所以,使用 https://github.com/JWalker1995/minisat/commit/a8cef9d932552b2ec155d5e0d44d8fe0efa3a235.patch为了第一, 和 https://github.com/niklasso/minisat/pull/17.patch第二个。

通用 url github.com/original/url/id 将变为 github.com/original/url/id.patch 用于生成补丁。

就运行命令而言,这变成了

  1. 将补丁下载到您的 git 存储库

    wget --output-document=issue1.patch https://github.com/JWalker1995/minisat/commit/a8cef9d932552b2ec155d5e0d44d8fe0efa3a235.patch
    wget --output-document=issue2.patch https://github.com/niklasso/minisat/pull/17.patch
    
  2. 应用补丁

    git apply issue1.patch
    

    检查更改,添加并提交。对补丁 2 重复相同的操作。

可以查看this blog post有关创建和应用补丁的精彩教程。

关于git - 将 github 提交/pull 请求作为补丁应用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28484186/

相关文章:

git - 在 Webstorm 8 上获得清晰的只读状态

svn - git svn dcommit 不工作

git gc --aggressive 与 git repack

jenkins - 位桶服务器 : Merge check - Minimum successful builds not enabling merge even after the condition is satisfied

git - 为 GitHub pull 请求更改 "base repo"

git - 使用 vim 作为 git 提交消息编写器,是否可以自动完成修改后的函数名称?

node.js - 新项目的 Git Init

amazon-web-services - 技能的应用程序 ID : Secure to include in public repository?

git - 如何使用命令行 git 从 Github 接受 pull 请求 (PR)

没有本地工作目录的 Github 远程仓库上的 Python 更新文件