git - 如何为特定提交生成 Git 补丁?

标签 git patch format-patch

我需要编写一个脚本来为 SHA-1 提交编号列表创建补丁。

我尝试使用 git format-patch <the SHA1> ,但是自该 SHA-1 值以来,它为每个提交生成了一个补丁。生成几百个补丁后,我不得不终止进程。

有没有办法只为特定的 SHA-1 值生成补丁?

最佳答案

尝试:

git <a href="https://www.kernel.org/pub/software/scm/git/docs/git-format-patch.html" rel="noreferrer noopener nofollow">format-patch</a> -1 <sha>

git format-patch -1 HEAD

根据上面的文档链接,-1 标志告诉 Git 应该在补丁中包含多少次提交;

-<n>

     Prepare patches from the topmost commits.


使用命令应用补丁:

git am < file.patch

关于git - 如何为特定提交生成 Git 补丁?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6658313/

相关文章:

git - 以增量方式使用过滤器分支的任何方式

git - Docker 将变量传递给运行 git clone 的 shell 脚本

git remote add 与其他 SSH 端口

git - SSH 不使用公钥进行身份验证 (Windows)

git - 通过主题获取 gerrit 补丁集(适用于多个存储库)

git am/格式补丁 : control format of line endings

Python:如何从加拿大的 shapefile 创建等值线图?

linux - 如何/在哪里找到要修复的 Linux 内核错误?

带有格式补丁的 git 多主题前缀