git log 命令是 Git 中用于查看提交历史的命令
- 常用的命令
git log:显示当前分支(HEAD)的全部提交记录,按照时间倒序排列。
git log <commit>:从指定的提交记录开始显示,按照时间倒序排列。
git log --follow <file>:显示指定文件的提交历史,并显示该文件的移动或重命名记录。
git log --pretty=<format>:使用指定的格式输出提交信息。常用的格式有 %H(提交哈希值)、%h(简短的提交哈希值)、%an(作者名)、%ae(作者邮箱)、%cn(提交者名)、%ce(提交者邮箱)、%s(提交说明)等。
git log --grep=<pattern>:仅显示包含指定模式的提交记录,模式可以是正则表达式。
git log --author=<name>:仅显示指定作者的提交记录。
git log --oneline:将每个提交记录压缩为一行,只显示提交哈希值和提交说明。
git log --graph:在提交记录前面绘制 ASCII 图形表示提交记录之间的关系。
git log --since=<date>:仅显示指定日期之后的提交记录,日期的格式可以是 “YYYY-MM-DD” 或 “<n> days ago” 等。
以上仅是 git log 命令的一些常用语法,更多详细的选项和参数可以通过 git help log 命令查看 Git 官方文档。
- 举例
- git log:默认倒序
commit 0972f7ff0e651f09a306dba791cc42024b8642c1 (HEAD -> develop, origin/develop, origin/HEAD)
Merge: 7cafc5c63 7935a683f
Author: Niels Lohmann <[email protected]>
Date: Sat May 15 19:26:34 2021 +0200
Merge pull request #2771 from offa/conan_package_url
Link to Conan Center package added
commit 7935a683f5ac931938ba7532534d19ed2b18cb80
Author: offa <[email protected]>
Date: Wed May 12 16:46:32 2021 +0200
link to conan package in readme
commit 7cafc5c63f412bf5e2583b8ea71b34996f6283ea
Author: Niels Lohmann <[email protected]>
Date: Mon May 10 14:23:27 2021 +0200
:memo: document Drone CI
- git log --reverse:正序显示
commit 4502e7e51c0569419c26e75fbdd5748170603e54
Author: Niels <[email protected]>
Date: Thu Jul 4 10:49:03 2013 +0200
- initial commit
commit b9465f8d65bb75b8751cf31b8c9d89045fe080bf
Author: Niels <[email protected]>
Date: Thu Jul 4 10:49:35 2013 +0200
- ignore DS_Stores
commit ac6ced6fb8946402ccf8bbd7db29cc1c63915b7f
Author: Niels <[email protected]>
Date: Thu Jul 4 10:54:16 2013 +0200
- a config file for travis
- git log -n:指定数量
$ git log -3
commit 0972f7ff0e651f09a306dba791cc42024b8642c1 (HEAD -> develop, origin/develop, origin/HEAD)
Merge: 7cafc5c63 7935a683f
Author: Niels Lohmann <[email protected]>
Date: Sat May 15 19:26:34 2021 +0200
Merge pull request #2771 from offa/conan_package_url
Link to Conan Center package added
commit 7935a683f5ac931938ba7532534d19ed2b18cb80
Author: offa <[email protected]>
Date: Wed May 12 16:46:32 2021 +0200
link to conan package in readme
commit 7cafc5c63f412bf5e2583b8ea71b34996f6283ea
Author: Niels Lohmann <[email protected]>
Date: Mon May 10 14:23:27 2021 +0200
:memo: document Drone CI
- git log <commit_id>:指定commid_id前的提交记录
$ git log -3 7cafc5c63f412bf5e2583b8ea71b34996f6283ea
commit 7cafc5c63f412bf5e2583b8ea71b34996f6283ea
Author: Niels Lohmann <[email protected]>
Date: Mon May 10 14:23:27 2021 +0200
:memo: document Drone CI
commit e856b507918f2d013089122eaa8bd9c925a9b815
Author: Niels Lohmann <[email protected]>
Date: Sun May 9 14:22:46 2021 +0200
:fire: remove arm build
commit a44b29ecf104d2a496fb4da875fca14655e207be
Author: Niels Lohmann <[email protected]>
Date: Sun May 9 13:52:16 2021 +0200
:wrench: fix paths
- git log --oneline:压缩提交记录仅显示一行
$ git log -3 --oneline
0972f7ff0 (HEAD -> develop, origin/develop, origin/HEAD) Merge pull request #2771 from offa/conan_package_url
7935a683f link to conan package in readme
7cafc5c63 :memo: document Drone CI
- git log --follow <filename>:指定文件的变更记录
$ git log --follow include/nlohmann/json.hpp
commit cdfe86548673808042d8abe1dc61e8a86b87dc58
Author: Niels Lohmann <[email protected]>
Date: Wed Apr 28 20:33:05 2021 +0200
:memo: add documentation for numbers
commit 35d79203ecafc0fbb5578c037184990512cf9fff
Author: raduteo <[email protected]>
Date: Mon Apr 12 19:47:02 2021 -0400
Update json.hpp
commit 6f551930e5c7ef397056de121c0da82f77573cca
Author: Niels Lohmann <[email protected]>
Date: Wed Mar 24 07:15:18 2021 +0100
:rotating_light: add new CI and fix warnings (#2561)
- git log --pretty=<format>
$ git log --pretty=%H-%h-%an-%ae-%cn-%ce-%s
0972f7ff0e651f09a306dba791cc42024b8642c1-0972f7ff0-Niels [email protected]@github.com-Merge pull request #2771 from offa/conan_package_url
7935a683f5ac931938ba7532534d19ed2b18cb80-7935a683f-offa-bm-dev@[email protected] to conan package in readme
7cafc5c63f412bf5e2583b8ea71b34996f6283ea-7cafc5c63-Niels [email protected] [email protected]:memo: document Drone CI
e856b507918f2d013089122eaa8bd9c925a9b815-e856b5079-Niels [email protected] [email protected]:fire: remove arm build
- git log --after/since <date>: 指定日期之后的提交记录
- after/since
$ git log --after 2021-05-10 -3
commit 0972f7ff0e651f09a306dba791cc42024b8642c1 (HEAD -> develop, origin/develop, origin/HEAD)
Merge: 7cafc5c63 7935a683f
Author: Niels Lohmann <[email protected]>
Date: Sat May 15 19:26:34 2021 +0200
Merge pull request #2771 from offa/conan_package_url
Link to Conan Center package added
commit 7935a683f5ac931938ba7532534d19ed2b18cb80
Author: offa <[email protected]>
Date: Wed May 12 16:46:32 2021 +0200
link to conan package in readme
commit 7cafc5c63f412bf5e2583b8ea71b34996f6283ea
Author: Niels Lohmann <[email protected]>
Date: Mon May 10 14:23:27 2021 +0200
:memo: document Drone CI
$ git log --since 2021-05-10 -3
commit 0972f7ff0e651f09a306dba791cc42024b8642c1 (HEAD -> develop, origin/develop, origin/HEAD)
Merge: 7cafc5c63 7935a683f
Author: Niels Lohmann <[email protected]>
Date: Sat May 15 19:26:34 2021 +0200
Merge pull request #2771 from offa/conan_package_url
Link to Conan Center package added
commit 7935a683f5ac931938ba7532534d19ed2b18cb80
Author: offa <[email protected]>
Date: Wed May 12 16:46:32 2021 +0200
link to conan package in readme
commit 7cafc5c63f412bf5e2583b8ea71b34996f6283ea
Author: Niels Lohmann <[email protected]>
Date: Mon May 10 14:23:27 2021 +0200
:memo: document Drone CI
--before
$ git log --before 2021-05-10 -3
commit e856b507918f2d013089122eaa8bd9c925a9b815
Author: Niels Lohmann <[email protected]>
Date: Sun May 9 14:22:46 2021 +0200
:fire: remove arm build
commit a44b29ecf104d2a496fb4da875fca14655e207be
Author: Niels Lohmann <[email protected]>
Date: Sun May 9 13:52:16 2021 +0200
:wrench: fix paths
commit 014724f362b0869e99e01c01cc86cc02198646d3
Author: Niels Lohmann <[email protected]>
Date: Sun May 9 13:49:42 2021 +0200
:alembic: change path
git log 命令是 Git 中用于查看提交历史的命令
- 常用的命令
git log:显示当前分支(HEAD)的全部提交记录,按照时间倒序排列。
git log <commit>:从指定的提交记录开始显示,按照时间倒序排列。
git log --follow <file>:显示指定文件的提交历史,并显示该文件的移动或重命名记录。
git log --pretty=<format>:使用指定的格式输出提交信息。常用的格式有 %H(提交哈希值)、%h(简短的提交哈希值)、%an(作者名)、%ae(作者邮箱)、%cn(提交者名)、%ce(提交者邮箱)、%s(提交说明)等。
git log --grep=<pattern>:仅显示包含指定模式的提交记录,模式可以是正则表达式。
git log --author=<name>:仅显示指定作者的提交记录。
git log --oneline:将每个提交记录压缩为一行,只显示提交哈希值和提交说明。
git log --graph:在提交记录前面绘制 ASCII 图形表示提交记录之间的关系。
git log --since=<date>:仅显示指定日期之后的提交记录,日期的格式可以是 “YYYY-MM-DD” 或 “<n> days ago” 等。
以上仅是 git log 命令的一些常用语法,更多详细的选项和参数可以通过 git help log 命令查看 Git 官方文档。
- 举例
- git log:默认倒序
commit 0972f7ff0e651f09a306dba791cc42024b8642c1 (HEAD -> develop, origin/develop, origin/HEAD)
Merge: 7cafc5c63 7935a683f
Author: Niels Lohmann <[email protected]>
Date: Sat May 15 19:26:34 2021 +0200
Merge pull request #2771 from offa/conan_package_url
Link to Conan Center package added
commit 7935a683f5ac931938ba7532534d19ed2b18cb80
Author: offa <[email protected]>
Date: Wed May 12 16:46:32 2021 +0200
link to conan package in readme
commit 7cafc5c63f412bf5e2583b8ea71b34996f6283ea
Author: Niels Lohmann <[email protected]>
Date: Mon May 10 14:23:27 2021 +0200
:memo: document Drone CI
- git log --reverse:正序显示
commit 4502e7e51c0569419c26e75fbdd5748170603e54
Author: Niels <[email protected]>
Date: Thu Jul 4 10:49:03 2013 +0200
- initial commit
commit b9465f8d65bb75b8751cf31b8c9d89045fe080bf
Author: Niels <[email protected]>
Date: Thu Jul 4 10:49:35 2013 +0200
- ignore DS_Stores
commit ac6ced6fb8946402ccf8bbd7db29cc1c63915b7f
Author: Niels <[email protected]>
Date: Thu Jul 4 10:54:16 2013 +0200
- a config file for travis
- git log <commit_id>:指定commid_id前的提交记录
commit 7cafc5c63f412bf5e2583b8ea71b34996f6283ea
Author: Niels Lohmann <[email protected]>
Date: Mon May 10 14:23:27 2021 +0200
:memo: document Drone CI
commit e856b507918f2d013089122eaa8bd9c925a9b815
Author: Niels Lohmann <[email protected]>
Date: Sun May 9 14:22:46 2021 +0200
:fire: remove arm build
commit a44b29ecf104d2a496fb4da875fca14655e207be
Author: Niels Lohmann <[email protected]>
Date: Sun May 9 13:52:16 2021 +0200
:wrench: fix paths
- git log -n:指定数量
$ git log -3
commit 0972f7ff0e651f09a306dba791cc42024b8642c1 (HEAD -> develop, origin/develop, origin/HEAD)
Merge: 7cafc5c63 7935a683f
Author: Niels Lohmann <[email protected]>
Date: Sat May 15 19:26:34 2021 +0200
Merge pull request #2771 from offa/conan_package_url
Link to Conan Center package added
commit 7935a683f5ac931938ba7532534d19ed2b18cb80
Author: offa <[email protected]>
Date: Wed May 12 16:46:32 2021 +0200
link to conan package in readme
commit 7cafc5c63f412bf5e2583b8ea71b34996f6283ea
Author: Niels Lohmann <[email protected]>
Date: Mon May 10 14:23:27 2021 +0200
:memo: document Drone CI
- git log --oneline:压缩提交记录仅显示一行
$ git log -3 --oneline
0972f7ff0 (HEAD -> develop, origin/develop, origin/HEAD) Merge pull request #2771 from offa/conan_package_url
7935a683f link to conan package in readme
7cafc5c63 :memo: document Drone CI
- git log --follow <filename>:指定文件的变更记录
$ git log --follow include/nlohmann/json.hpp
commit cdfe86548673808042d8abe1dc61e8a86b87dc58
Author: Niels Lohmann <[email protected]>
Date: Wed Apr 28 20:33:05 2021 +0200
:memo: add documentation for numbers
commit 35d79203ecafc0fbb5578c037184990512cf9fff
Author: raduteo <[email protected]>
Date: Mon Apr 12 19:47:02 2021 -0400
Update json.hpp
commit 6f551930e5c7ef397056de121c0da82f77573cca
Author: Niels Lohmann <[email protected]>
Date: Wed Mar 24 07:15:18 2021 +0100
:rotating_light: add new CI and fix warnings (#2561)
- git log --pretty=<format>
$ git log --pretty=%H-%h-%an-%ae-%cn-%ce-%s
0972f7ff0e651f09a306dba791cc42024b8642c1-0972f7ff0-Niels [email protected]@github.com-Merge pull request #2771 from offa/conan_package_url
7935a683f5ac931938ba7532534d19ed2b18cb80-7935a683f-offa-bm-dev@[email protected] to conan package in readme
7cafc5c63f412bf5e2583b8ea71b34996f6283ea-7cafc5c63-Niels [email protected] [email protected]:memo: document Drone CI
e856b507918f2d013089122eaa8bd9c925a9b815-e856b5079-Niels [email protected] [email protected]:fire: remove arm build
- git log --after/since <date>: 指定日期之后的提交记录
- after/since
$ git log --after 2021-05-10 -3
commit 0972f7ff0e651f09a306dba791cc42024b8642c1 (HEAD -> develop, origin/develop, origin/HEAD)
Merge: 7cafc5c63 7935a683f
Author: Niels Lohmann <[email protected]>
Date: Sat May 15 19:26:34 2021 +0200
Merge pull request #2771 from offa/conan_package_url
Link to Conan Center package added
commit 7935a683f5ac931938ba7532534d19ed2b18cb80
Author: offa <[email protected]>
Date: Wed May 12 16:46:32 2021 +0200
link to conan package in readme
commit 7cafc5c63f412bf5e2583b8ea71b34996f6283ea
Author: Niels Lohmann <[email protected]>
Date: Mon May 10 14:23:27 2021 +0200
:memo: document Drone CI
$ git log --since 2021-05-10 -3
commit 0972f7ff0e651f09a306dba791cc42024b8642c1 (HEAD -> develop, origin/develop, origin/HEAD)
Merge: 7cafc5c63 7935a683f
Author: Niels Lohmann <[email protected]>
Date: Sat May 15 19:26:34 2021 +0200
Merge pull request #2771 from offa/conan_package_url
Link to Conan Center package added
commit 7935a683f5ac931938ba7532534d19ed2b18cb80
Author: offa <[email protected]>
Date: Wed May 12 16:46:32 2021 +0200
link to conan package in readme
commit 7cafc5c63f412bf5e2583b8ea71b34996f6283ea
Author: Niels Lohmann <[email protected]>
Date: Mon May 10 14:23:27 2021 +0200
:memo: document Drone CI
--before
$ git log --before 2021-05-10 -3
commit e856b507918f2d013089122eaa8bd9c925a9b815
Author: Niels Lohmann <[email protected]>
Date: Sun May 9 14:22:46 2021 +0200
:fire: remove arm build
commit a44b29ecf104d2a496fb4da875fca14655e207be
Author: Niels Lohmann <[email protected]>
Date: Sun May 9 13:52:16 2021 +0200
:wrench: fix paths
commit 014724f362b0869e99e01c01cc86cc02198646d3
Author: Niels Lohmann <[email protected]>
Date: Sun May 9 13:49:42 2021 +0200
:alembic: change path
标签:git,log,Author,Niels,Date,commit
From: https://www.cnblogs.com/faithlocus/p/17332540.html