问题描述
我需要编写一个脚本来为SHA1提交编号列表创建补丁.
I need to write a script that creates patches for a list of SHA1 commit numbers.
我尝试使用git format-patch <the SHA1>
,但是自SHA1以来,每次提交都会生成一个补丁.生成几百个补丁后,我不得不终止该过程.
I tried using git format-patch <the SHA1>
, but that generated a patch for each commit since that SHA1. After a few hundred patches were generated, I had to kill the process.
是否有一种仅针对特定SHA1生成补丁的方法?
Is there a way to generate a patch only for the specific SHA1?
推荐答案
尝试:
git format-patch -1 <sha>
或
git format-patch -1 HEAD
根据上面的文档链接,-1
标志告诉git补丁中应包含多少个提交;
According to the documentation link above, the -1
flag tells git how many commits should be included in the patch;
从最顶层的提交准备补丁.
Prepare patches from the topmost commits.
使用以下命令应用补丁:
Apply the patch with the command:
git am < file.patch
这篇关于如何为特定提交生成git补丁?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!