git log,显示commit log
语法
1 | git log [<options>] [<revision range>] [[\--] <path>…] |
选项:
--decorate[=short|full|auto|no]
如果有引用指向commit,显示这个引用。
1 2 3 4 5 6 7 | $ git log --decorate commit ec05b1a7... (HEAD -> rpi-4.14.y, origin/rpi-4.14.y, origin/HEAD) Merge: 82c4c8e d88700f Author: popcornmix <popcornmix@gmail.com> Date: Mon May 21 15:43:53 2018 +0100 Merge remote-tracking branch 'stable/linux-4.14.y' into rpi-4.14.y |
--full-diff
没有这个选项,git log -p <path>只会显示path中文件的diff,不会显示同commit中其它文件的diff。
<revision range>
显示特定范围内的commit。origin..HEAD
[--] <path>...
只是显示这些路径的commit。
Commit Limiting
-<number>
-n <number>
--max-count=<number>
只显示<number>条输出。
--skip=<number>
跳过<number>条输出
--since=<date>
--after=<date>
显示date之后的commit。
--until=<date>
--before=<date>
显示date之前的commit。
--author=<pattern>
--committer=<pattern>
按作者显示
--grep=<pattern>
显示匹配固定格式的commit
--all-match
显示匹配所有--grep的commit,默认只要匹配任何一个就显示。
--invert-grep
显示不匹配grep的commit。
-i
--regexp-ignore-case
匹配时忽略大小写。
-E
--extended-regexp
pattern当做扩看正则表达式。
-F
--fixed-strings
pattern当做普通字符串。
--merges
只显示merge commit,即--min-parents=2
--min-parents=<number>
--max-parents=<number>
根据merge的个数显示。
--first-parent
只显示第一个parent
--not
反转后续的含义
--all
所有的分支refs/
--branches[=<pattern>]
refs/heads下所有的分支
--tags[=<pattern>]
refs/tags下所有的refs
--remotes[=<patter>]
refs/remotes下所有的refs
History Simplification
不懂
Commit Ordering
--date-order
--author-date-order
--topo-order
--reverse
Commit Formatting
--pretty[=<format>]
--format=<format>
格式有online,short,medium, full,fuller,email,raw,或者自定义字符串
--abbrev-commit
缩短commit id的显示
--oneline
等价于--pretty=oneline --abbrev-commit
COMMON DIFF options
-p
-u
--patch
显示改动的patch
--state
--numstat
--shortstat
--dirstat
显示改动的文件,以及改动信息
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | $ git log --stat commit ec05b1a7860dbeee7d3fc3390c4d2ba8ddaeb8a9 Merge: 82c4c8e d88700f Author: popcornmix <popcornmix@gmail.com> Date: Mon May 21 15:43:53 2018 +0100 Merge remote-tracking branch 'stable/linux-4.14.y' into rpi-4.14.y commit 82c4c8e6c6bb0df47aa1fff86113d9fca2d3a0e5 Author: Phil Elwell <phil@raspberrypi.org> Date: Sun May 20 19:31:11 2018 +0100 config: Add KEYBOARD_MATRIX=m See: https://github.com/raspberrypi/linux/pull/2150 Signed-off-by: Phil Elwell <phil@raspberrypi.org> arch/arm/configs/bcm2709_defconfig | 1 + arch/arm/configs/bcmrpi_defconfig | 1 + arch/arm64/configs/bcmrpi3_defconfig | 1 + 3 files changed, 3 insertions(+) |
--name-status
显示改动的文件,以及状态。
1 2 3 4 5 6 7 8 9 10 11 12 13 | commit 82c4c8e6c6bb0df47aa1fff86113d9fca2d3a0e5 Author: Phil Elwell <phil@raspberrypi.org> Date: Sun May 20 19:31:11 2018 +0100 config: Add KEYBOARD_MATRIX=m See: https://github.com/raspberrypi/linux/pull/2150 Signed-off-by: Phil Elwell <phil@raspberrypi.org> M arch/arm/configs/bcm2709_defconfig M arch/arm/configs/bcmrpi_defconfig M arch/arm64/configs/bcmrpi3_defconfig |
--name-only
只显示改动的文件