首页 > 其他分享 >git log

git log

时间:2023-04-19 10:57:43浏览次数:39  
标签:git log Author Niels Date commit

git log 命令是 Git 中用于查看提交历史的命令

  1. 常用的命令
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 官方文档。
  1. 举例
  • 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
  1. 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
  1. 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


  1. 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

  1. 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)

  1. 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
  1. 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 中用于查看提交历史的命令

  1. 常用的命令
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 官方文档。
  1. 举例
  • 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
  1. 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

  1. 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
  1. 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

  1. 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)

  1. 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
  1. 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

相关文章

  • gitlab与openldap做权限认证
    1.gitlab开启并配置ldap编辑gitlab.rb配置文件打开编辑gitlab.rb配置文件:vi/etc/gitlab/gitlab.rbgitlab_rails['ldap_enabled']=true#gitlab_rails['prevent_ldap_sign_in']=falsegitlab_rails[‘ldap_servers’]=YAML.load<<-‘EOS’**EOS**为ldap相......
  • Git
    1.版本控制版本控制是一种在开发过程中,用于管理我们对文件、目录或工程等内容的修改历史,方便查看历史记录,备份以便恢复以前版本的软件工程技术。实现跨区域多人协同开发追踪和记录一个或多个文件的历史记录组织和保护源代码和文档统计工作量并行开发,提高工作量记录跟踪整......
  • gitbook的安装与使用
    gitbook的安装与使用一、安装gitbook1.1、基础条件查看是否安装了nodejs#node-vv10.22.0#npm-v6.14.61.2、安装gitbook使用npm安装gitbook#sudonpminstall-ggitbook-cli二、使用gitbook2.1、创建书籍在指定的目录中,通过gitbook官方模板创建书籍#cd/......
  • cronolog工具切割nohup运行日志
    1.日志分割:随着JAVA服务线上运行,默认单个日志文件占用磁盘空间会越来越大,查看文件信息不方便,故需要对日志文件进行分割,这里借用第三方工具cronolog切割,因为网上有很多种切分方式,要么不行要么不好用。 2.安装cronologA.yum在线安装:yuminstall-ycronolog;B.rpm离......
  • gitbook的安装与使用
    gitbook的安装与使用一、安装gitbook1.1、基础条件查看是否安装了nodejs#node-vv10.22.0#npm-v6.14.61.2、安装gitbook使用npm安装gitbook#sudonpminstall-ggitbook-cli二、使用gitbook2.1、创建书籍在指定的目录中,通过gitbook官方模板创建书籍#cd/......
  • 【工具类】Git的初次使用,以及与Gitee的关联
    一、下载与安装可以去Git官网下载,链接......
  • Redis高级 哈希类型、列表类型、集合类型、有序集合(zset)、慢查询、pipeline与事务
    哈希类型###1---hget,hset,hdelhgetkeyfield#获取hashkey对应的field的value时间复杂度为o(1)hsetkeyfieldvalue#设置hashkey对应的field的value值时间复杂度为o(1)hdelkeyfield#删除hashkey对应的field的值时间复杂度为o(1)#测试hsetuser:1:infoage......
  • 【Azure 应用服务】当在Azure App Service的门户上 Log Stream 日志无输出,需要如何操
    问题描述在AzureAppService的门户上LogStream日志无输出,需要如何操作让其输出ApplicationLogs呢?如下图所示:问题解答请注意,上图中提示说:Applicationlogsareswitchedoff. YoucanturnthemonusingtheAppServiceLogsSettings.应用日志关闭,可以通过AppServiceL......
  • 【Redis】哈希类型 列表类型 集合类型 有序集合 慢查询 pipeline与事务 发布订阅 Bitm
    目录昨日回顾今日内容1哈希类型2列表类型3集合类型4有序集合(zset)5慢查询6pipeline与事务7发布订阅8Bitmap位图9HyperLogLog作业昨日回顾#1redis介绍 -特性#速度快:10wops(每秒10w读写),数据存在内存中,c语言实现,单线程模型#持久化:rdb和aof#多种数据结......
  • 【GIT】学习day03 | 如何生成并配置SSH公钥
    快速笔记:1、注册并激活码云账号2、生成并配置SSH公钥(运行[email protected]检测SSH公钥是否配置成功)3、创建空白的码云仓库4、把本地项目上传到码云对应的空白仓库中双击进入 打开里面复制公钥 添加到gitee上即可 新建仓库步骤 然后创建就完事了,不过一开始......