git 查看最新commit提交时间(具体到时分秒)

git 查看最新commit提交时间 使用服务器时间 以及如何自定义显示格式

使用服务器时间查看最新提交时间:
可以使用 git log 命令来查看最新提交的时间,该时间默认显示为作者提交时间。

$ git log -1 --format="%cd"

如果想查看提交者提交时间,可以将 %cd 改为 %cr:

$ git log -1 --format="%cr"

自定义格式显示提交时间:
可以使用 --date-format 参数来自定义显示格式。下面是一些常用的格式选项:

格式选项 说明

%c	类似 %(format:%a %b %d %H:%M:%S %Y %z)
%ad	日期格式(比如:Sat Oct 5 16:19:00 2019 -0400%at	时间戳(比如:1570309140%ar	相对时间(比如:2 months ago)

例如,可以使用以下命令来显示最新提交时间以及其它信息:

$ git log -1 --pretty=format:"%h - %an, %ar : %s" --date=format:"%Y-%m-%d %H:%M:%S"

其中,%h 表示短 SHA-1 值,%an 表示提交者名字,%ar 表示相对时间,%s 表示提交信息。–date=format:“%Y-%m-%d %H:%M:%S” 是自定义的日期格式。

更多关于 git log 命令的用法可以通过 man git-log 或者 git help log 查看。

参考https://linuxcpp.0voice.com/?id=19244

相关推荐

  1. git 查看最新commit提交时间(具体时分秒)

    2024-01-01 18:04:03       38 阅读
  2. Git】Conventional Commit提交规范

    2024-01-01 18:04:03       28 阅读
  3. git commit 提交信息规范

    2024-01-01 18:04:03       15 阅读

最近更新

  1. TCP协议是安全的吗?

    2024-01-01 18:04:03       16 阅读
  2. 阿里云服务器执行yum,一直下载docker-ce-stable失败

    2024-01-01 18:04:03       16 阅读
  3. 【Python教程】压缩PDF文件大小

    2024-01-01 18:04:03       15 阅读
  4. 通过文章id递归查询所有评论(xml)

    2024-01-01 18:04:03       18 阅读

热门阅读

  1. CAN,SPI,IIC,USART每帧的组成

    2024-01-01 18:04:03       36 阅读
  2. LeetCode976. Largest Perimeter Triangle

    2024-01-01 18:04:03       29 阅读
  3. Mybatis之增删改查

    2024-01-01 18:04:03       29 阅读
  4. Channel底层简记

    2024-01-01 18:04:03       25 阅读
  5. SOLID之依赖倒置原则

    2024-01-01 18:04:03       49 阅读
  6. chrome.tabs.executeScrip To chrome.scripting.executeScript

    2024-01-01 18:04:03       35 阅读
  7. Python面试之装饰器

    2024-01-01 18:04:03       34 阅读