git-log 和 git-whatchanged 的​​区别?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/10022722/
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 06:42:53  来源:igfitidea点击:

Difference between git-log and git-whatchanged?

gitgit-log

提问by Alexander Bird

  1. Given this answerto another question, and
  2. given that the man pages for both git-logand git-whatchangedsay they pull from git-rev-list...
  1. 给出另一个问题的答案,并且
  2. 鉴于git-loggit-whatchanged的手册页都说它们是从git-rev-list 中提取的...

...what then is the difference between the two commands? Why bother having both of them?

...那么这两个命令之间的区别是什么?为什么要同时拥有它们?

采纳答案by VonC

The commit 52f425e1(August, 30th 2013) mentions:

提交52f425e1(八月30日2013)提到:

Encourage new users to use 'log' instead. These days, these commands are unified and just have different defaults.

'git log' only allowed you to view the log messages and no diffs when it was added in early June 2005. It was only in early April 2006 that the command learned to take diff options.
Because of this, power users tended to use 'whatchanged' that already existed since mid May 2005 and supported diff options.

鼓励新用户改用“ log”。这些天来,这些命令是统一的,只是有不同的默认值

' git log' 在 2005 年 6 月上旬添加时仅允许您查看日志消息而没有差异。直到 2006 年 4 月上旬,该命令才学会采用差异选项。
因此,高级用户倾向于使用whatchanged自 2005 年 5 月中旬以来已经存在并支持差异选项的“ ”。



That is what the new version of the man page for git whatchangedwill say now:

这就是新版本的手册页git whatchanged现在会说的:

New users are encouraged to use git loginstead. The whatchangedcommand is essentially the same as git logbut defaults to show the raw format diff output and to skip merges.

The command is kept primarily for historical reasons; fingers of many people who learned Git long before git logwas invented by reading Linux kernel mailing list are trained to type it.

鼓励新用户git log改用。该 whatchanged命令本质上与git log但默认显示原始格式差异输出并跳过合并相同。

保留该命令主要是出于历史原因;许多很久以前git log通过阅读 Linux 内核邮件列表学习 Git 的人的手指都被训练来键入它

As torekcomments, the git logequivalent would be:

正如torek评论的那样git log相当于:

git log --raw --no-merges

(That would avoid this question)

(那会避免这个问题

回答by GoZoner

In their simplest form, 'git log' shows each commit (sha, author, date, message) whereas 'git whatchanged' shows the commit plus files that changed. For example:

'git log' 以最简单的形式显示每个提交(sha、作者、日期、消息),而 'git whatchanged' 显示提交加上更改的文件。例如:

$ git log
commit db9f525674443314a9822a6bd6c3acce49c8f8d6
Author: ...
Date:   Wed Apr 4 22:55:33 2012 -0700

Add more

commit eed0b7aa3cad5d985b5f1d52f3c0605339c119a1
Author: ...
Date:   Tue Apr 3 20:36:04 2012 -0700

del bing/one.c

but for whatchanged:

但对于改变了什么:

$ git whatchanged
commit db9f525674443314a9822a6bd6c3acce49c8f8d6
Author: ...
Date:   Wed Apr 4 22:55:33 2012 -0700

Add more

:100644 100644 f2e4113... d415016... M  bar.c

commit eed0b7aa3cad5d985b5f1d52f3c0605339c119a1
Author: ...
Date:   Tue Apr 3 20:36:04 2012 -0700

del bing/one.c

:100644 000000 e69de29... 0000000... D  bing/one.c

Plenty of options exist to change the output of each command. For example 'git whatchanged -p' shows the changes in diff/patch form.

有很多选项可以更改每个命令的输出。例如 'git whatchanged -p' 显示差异/补丁形式的变化。

回答by bernardo

I don't totally agree. Can you see merge changed files with log?

我不完全同意。你能看到合并更改的文件log吗?

I didn't find this functionality and is very useful for to know when a file was merged in some branch, example:

我没有找到这个功能,对于知道文件何时合并到某个分支非常有用,例如:

file c.cin branch1has a commit date from 1/1/2012, if you do a merge to branch2, and later would like to follow the day that that commit was introduced in branch2, can git loghelp? If you have the merges you could search in them with git whatchanged -m sha1

file c.cinbranch1的提交日期为 2012 年 1 月 1 日,如果您对 进行合并branch2,并且稍后想跟踪该提交被引入的那一天branch2,可以提供git log帮助吗?如果你有合并,你可以在它们中搜索git whatchanged -m sha1