我需要编写一个脚本来为 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/