如何获得特定提交的“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
How do I get a "git log" patch for a specific commit
提问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-names
but 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-patch
for 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