Git 差异总结?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/37582250/
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
Git diff in summary?
提问by Justin Moh
With git pull
, it shows a diff summary like this:
使用git pull
,它会显示如下差异摘要:
Updating 6a78751..811f788
Fast-forward
app/Http/Controllers/SaleController.php | 7 +-
.../views/pages/sale/create.blade.php | 137 +++++++++++++---
resources/views/pages/sale/index.blade.php | 4 +-
resources/views/pages/sale/show.blade.php | 5 +-
4 files changed, 123 insertions(+), 30 deletions(-)
Is there a way to use commands like git diff
to get similar output?
有没有办法使用git diff
类似的命令来获得类似的输出?
回答by Tony Vincent
git log --stat
will show the amount each file was changed.
git log --stat
将显示每个文件的更改量。
git whatchanged
gives some detail into the files that were modified.
git whatchanged
给出了修改过的文件的一些细节。
git diff --stat <sha1> <sha2>
gives the files and the amount of changes between two commits.
git diff --stat <sha1> <sha2>
给出文件和两次提交之间的更改量。
git diff --stat <branch>
to compare to another branch (e.g. master)
git diff --stat <branch>
与另一个分支进行比较(例如 master)
回答by Paul Hicks
git diff
is indeed the command you seek. In particular you want
git diff
确实是您寻求的命令。特别是你想要
git diff --stat
Other similar reports are available using
其他类似的报告可使用
git diff --numstat
git diff --shortstat
git diff --dirstat
git diff --name-status
回答by VonC
Is there a way to use commands like git diff to get similar output?
有没有办法使用像 git diff 这样的命令来获得类似的输出?
With Git 2.17 (Q2 2018), there actually is, with a result a bit more complete than git diff -stat
:
使用 Git 2.17(2018 年第二季度),实际上有一个比git diff -stat
以下更完整的结果:
"git diff
" and friends learned "--compact-summary
" that shows the
information usually given with the "--summary
" option on the same
line as the diffstat output of the "--stat
" option (which saves
vertical space and keeps info on a single path at the same place).
" git diff
" 和朋友们了解到 " --compact-summary
" 显示了通常与 " --summary
" 选项一起提供的信息,与 " " 选项的 diffstat 输出位于同一行--stat
(这样可以节省垂直空间并将信息保留在同一位置的单个路径上)。
See commit ddf88fa(24 Feb 2018), and commit c905cbc(01 Feb 2018) by Nguy?n Thái Ng?c Duy (pclouds
).
(Merged by Junio C Hamano -- gitster
--in commit 868f7d2, 14 Mar 2018)
请参阅Nguy?n Thái Ng?c Duy ( )提交的 ddf88fa(2018 年 2 月 24 日)和c905cbc(2018 年 2 月 1 日)。(由Junio C Hamano合并-- --在868f7d2 提交中,2018 年 3 月 14 日)pclouds
gitster
diff
: add--compact-summary
Certain information is currently shown with --summary, but when used in combination with --stat it's a bit hard to read since info of the same file is in two places (--stat and --summary).
On top of that, commits that add or remove files double the number of display lines, which could be a lot if you add or remove a lot of files.
--compact-summary
embeds most of--summary
back in--stat
in the little space between the file name part and the graph line, e.g. with commit 0433d53:Documentation/merge-config.txt | 4 + builtin/merge.c | 2 + ...-pull-verify-signatures.sh (new +x) | 81 ++++++++++++++ t/t7612-merge-verify-signatures.sh | 45 ++++++++ 4 files changed, 132 insertions(+)
It helps both condensing information and saving some text space.
What's new in diffstat is:
- A new 0644 file is shown as
(new)
- A new 0755 file is shown as
(new +x)
- A new symlink is shown as
(new +l)
- A deleted file is shown as
(gone)
- A mode change adding executable bit is shown as
(mode +x)
- A mode change removing it is shown as
(mode -x)
Note that
--compact-summary
does not contain all the information--summary
provides. Rewrite percentage is not shown but it could be added later, likeR50%
orC20%
.
diff
: 添加--compact-summary
当前使用--summary 显示某些信息,但是当与--stat 结合使用时,由于同一文件的信息位于两个位置(--stat 和--summary),因此有点难以阅读。
最重要的是,添加或删除文件的提交使显示行数加倍,如果添加或删除大量文件,则显示行数可能会很多。
--compact-summary
嵌入大部分--summary
早在--stat
文件名部分和图线,例如,与之间的空间不大 提交0433d53:Documentation/merge-config.txt | 4 + builtin/merge.c | 2 + ...-pull-verify-signatures.sh (new +x) | 81 ++++++++++++++ t/t7612-merge-verify-signatures.sh | 45 ++++++++ 4 files changed, 132 insertions(+)
它有助于压缩信息并节省一些文本空间。
diffstat 的新功能是:
- 一个新的 0644 文件显示为
(new)
- 一个新的 0755 文件显示为
(new +x)
- 一个新的符号链接显示为
(new +l)
- 删除的文件显示为
(gone)
- 添加可执行位的模式更改显示为
(mode +x)
- 删除它的模式更改显示为
(mode -x)
请注意,
--compact-summary
不包含--summary
提供的所有信息 。未显示重写百分比,但可以稍后添加,例如R50%
或C20%
。