如何获得特定提交的“git log”补丁

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5891531/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 05:25:17  来源:igfitidea点击:

How do I get a "git log" patch for a specific commit

gitversion-controlpatchgit-log

提问by Jonathan Day

If I have a commit hash that has not yet been pushed to origin, how can I generate a patch for that commit only. I would like to use git log -p --no-namesbut can't see a switch to pass in a specific commit hash. Should I be using a different git command?

如果我有一个尚未推送到原点的提交哈希,我如何仅为该提交生成补丁。我想使用git log -p --no-names但看不到传递特定提交哈希的开关。我应该使用不同的 git 命令吗?

回答by manojlds

For git log patch:

对于 git 日志补丁:

git log -p -1 <commit>

You should be using git format-patchfor patches though:

你应该使用git format-patch补丁:

git format-patch -1 <commit>

http://www.kernel.org/pub/software/scm/git/docs/git-format-patch.html

http://www.kernel.org/pub/software/scm/git/docs/git-format-patch.html