在 git 中,如何为最后 2+ 创建单个补丁?修订?
我想为最后两个修订创建一个补丁。
git format-patch -2
给了我 2 个补丁文件,每个修订版
git format-patch HEAD~2..HEAD
都有一个相同的东西。
git format-patch -1 HEAD~2..HEAD
给出单个文件,但仅包含最后修订版的更改。
在git中有什么办法可以做到这一点吗?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
不过,它不会有任何 format-patch 的每次提交元数据。
It won't have any of format-patch's per-commit metadata, though.
使用 --stdout 选项,然后将其放入文件中。
像这样:
这将保留每次提交的元数据。
Use the --stdout option and then cat it to a file.
Like so:
This will keep the per-commit metadata.
使用 Git 2.20(2018 年第 4 季度)及更高版本,您现在拥有:
git format-patch --interdiff
。两者都有助于解释此版本与求职信中之前的尝试(或在树破折号之后作为评论)之间的差异。
请参阅 提交 ee6cbf7、提交 3fcc7a2, 提交3b02641,提交 5ac290f,提交126facf,提交 fa5b7ea(2018 年 7 月 22 日),作者:Eric Sunshine (
sunshineco
) 。(由 Junio C Hamano --
gitster
-- 合并于 提交 688cb1c,2018 年 9 月 17 日)请参阅 提交 40ce416、提交 8631bf1, 提交4ee9968,提交 2e6fd71,提交 31e2617,提交 73a834e,提交 2566865,提交 87f1b2d(2018 年 7 月 22 日),作者:Eric Sunshine (
sunshineco
)。(由 Junio C Hamano --
gitster
-- 合并于 提交 881c019,2018 年 9 月 17 日)使用 Git 2.46(2024 年第 3 季度),第 15 批,“
git format-patch --interdiff
"(man) 对于多补丁系列,学会了自动打开求职信(除非被告知永远不要使用“--no-cover-letter
”等启用求职信) )。请参阅提交f96c385,提交 bc665cd(2024 年 6 月 7 日),作者:Rubén Justo (
rjusto
)。(由 Junio C Hamano --
gitster
-- 合并于 提交 9071453,2024 年 6 月 20 日)With Git 2.20 (Q4 2018) and more, you now have:
git format-patch --interdiff
.git format-patch --rangediff
.Both are helping to explain the difference between this version and the previous attempt in the cover letter (or after the tree-dashes as a comment).
See commit ee6cbf7, commit 3fcc7a2, commit 3b02641, commit 5ac290f, commit 126facf, commit fa5b7ea (22 Jul 2018) by Eric Sunshine (
sunshineco
).(Merged by Junio C Hamano --
gitster
-- in commit 688cb1c, 17 Sep 2018)See commit 40ce416, commit 8631bf1, commit 4ee9968, commit 2e6fd71, commit 31e2617, commit 73a834e, commit 2566865, commit 87f1b2d (22 Jul 2018) by Eric Sunshine (
sunshineco
).(Merged by Junio C Hamano --
gitster
-- in commit 881c019, 17 Sep 2018)With Git 2.46 (Q3 2024), batch 15, "
git format-patch --interdiff
"(man) for multi-patch series learned to turn on cover letters automatically (unless told never to enable cover letter with "--no-cover-letter
" and such).See commit f96c385, commit bc665cd (07 Jun 2024) by Rubén Justo (
rjusto
).(Merged by Junio C Hamano --
gitster
-- in commit 9071453, 20 Jun 2024)您可以执行以下操作:
对分支 tmp 的提交将与 2 个单独的提交相同。
You could do something like:
The commit to branch tmp will be the same as the 2 individual commits.