git 如何显示提交做了什么?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1157818/
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 to show what a commit did?
提问by Sam Liao
A stupid way I know is:
我知道的一个愚蠢的方法是:
git diff commit-number1 commit-number2
any better way?
有什么更好的方法吗?
I mean I want to know the commit1 itself, I don't want to add the commit2 before it as parameter.
我的意思是我想知道 commit1 本身,我不想在它之前添加 commit2 作为参数。
回答by Bombe
回答by Mark van Lent
Does
做
$ git log -p
do what you need?
做你需要的吗?
Check out the chapter on Git Login the Git Community Book for more examples. (Or look at the the documentation.)
有关更多示例,请查看Git 社区手册中有关 Git 日志的章节。(或查看文档。)
Update: As others (Jakuband Bombe) already pointed out: although the above works, git showis actually the command that is intended to do exactly what was asked for.
更新:正如其他人(Jakub和Bombe)已经指出的那样:尽管上述方法有效,但git show实际上是旨在完全按照要求执行的命令。
回答by Geoffrey Hale
TL;DR
TL; 博士
git show <commit>
git show <commit>
Show
展示
To showwhat a commit did with stats:
要显示提交对统计数据的作用:
git show <commit> --stat
Log
日志
To show commit logwith differences introduced for each commit in a range:
显示提交日志,并为范围内的每个提交引入差异:
git log -p <commit1> <commit2>
What is <commit>
?
什么是<commit>
?
Each commit has a unique id we reference here as <commit>
. The unique id is an SHA-1 hash – a checksum of the content you're storing plus a header. #TMI
每个提交都有一个唯一的 id,我们在这里引用为<commit>
. 唯一 id 是一个 SHA-1 哈希值——您存储的内容的校验和加上一个标头。#TMI
If you don't know your <commit>
:
如果你不知道你的<commit>
:
git log
to view the commit historyFind the commit you care about.
git log
要查看提交历史找到你关心的提交。
回答by Harvey Lin
I found out that "git show --stat" is the best out of all here, gives you a brief summary of the commit, what files did you add and modify without giving you whole bunch of stuff, especially if you changed a lot files.
我发现“git show --stat”是这里最好的,它为您提供了提交的简短摘要,您添加和修改了哪些文件而没有提供大量内容,特别是如果您更改了很多文件.
回答by 1800 INFORMATION
This is one way I know of. With git
, there always seems to be more than one way to do it.
这是我所知道的一种方式。使用git
,似乎总是有不止一种方法可以做到。
git log -p commit1 commit2