如何为特定的提交生成Git补丁? [英] How can I generate a Git patch for a specific commit?

查看:53
本文介绍了如何为特定的提交生成Git补丁?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I need to write a script that creates patches for a list of SHA-1 commit numbers.

我尝试使用 git format-patch< SHA1> ,但是自SHA-1以来,每次提交都会生成补丁.生成几百个补丁后,我不得不终止该过程.

I tried using git format-patch <the SHA1>, but that generated a patch for each commit since that SHA-1 value. After a few hundred patches were generated, I had to kill the process.

是否有一种仅针对特定SHA-1值生成补丁的方法?

Is there a way to generate a patch only for the specific SHA-1 value?

推荐答案

尝试:

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;

-< n>

-<n>

从最顶层的提交准备补丁.

     Prepare patches from the topmost commits.


使用以下命令应用补丁:


Apply the patch with the command:

git am < file.patch

这篇关于如何为特定的提交生成Git补丁?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆