git log 修改date显示格式

$ git config --global user.name "Your Name"
$ git config --global user.email your@example.com

$ git config --list 

user.name=yueruitao
user.email=1316751406@qq.com
core.repositoryformatversion=0
core.filemode=false
core.bare=false
core.logallrefupdates=true
core.ignorecase=true

******
git config log.date iso-local                2018-11-03 03:30:04 +0000

git config log.date iso-strict-local        2018-11-03T03:30:04+00:00  
***
--date=<format>

Only takes effect for dates shown in human-readable format, such as when using --pretty. log.date config variable sets a default value for the log command’s --date option. By default, dates are shown in the original time zone (either committer’s or author’s). If -local is appended to the format (e.g., iso-local), the user’s local time zone is used instead.

--date=relative shows dates relative to the current time, e.g. “2 hours ago”. The -local option has no effect for --date=relative.

--date=local is an alias for --date=default-local.

--date=iso (or --date=iso8601) shows timestamps in a ISO 8601-like format. The differences to the strict ISO 8601 format are:

a space instead of the T date/time delimiter

a space between time and time zone

no colon between hours and minutes of the time zone

--date=iso-strict (or --date=iso8601-strict) shows timestamps in strict ISO 8601 format.

+ --date=rfc (or --date=rfc2822) shows timestamps in RFC 2822 format, often found in email messages.

+ --date=short shows only the date, but not the time, in YYYY-MM-DD format.

+ --date=raw shows the date as seconds since the epoch (1970-01-01 00:00:00 UTC), followed by a space, and then the timezone as an offset from UTC (a + or - with four digits; the first two are hours, and the second two are minutes). I.e., as if the timestamp were formatted with strftime("%s %z")). Note that the -local option does not affect the seconds-since-epoch value (which is always measured in UTC), but does switch the accompanying timezone value.

+ --date=unix shows the date as a Unix epoch timestamp (seconds since 1970). As with --raw, this is always in UTC and therefore -local has no effect.

+ --date=format:... feeds the format ... to your system strftime, except for %z and %Z, which are handled internally. Use --date=format:%c to show the date in your system locale’s preferred format. See the strftime manual for a complete list of format placeholders. When using -local, the correct syntax is --date=format-local:....

+ --date=default is the default format, and is similar to --date=rfc2822, with a few exceptions:
there is no comma after the day-of-week
the time zone is omitted when the local time zone is used

 

<think>好的,用户让我介绍一下Git log。首先,我需要确定用户对Git的基础知识了解多少。可能用户已经知道基本的版本控制概念,但需要更深入了解如何查看提交历史。 接下来,我应该回顾Git log的基本功能,它用于查看项目的提交历史。用户可能想知道常用的选项和参数,比如如何简化输出、查看差异,或者按时间、作者过滤提交记录。需要分步骤介绍,让用户能够逐步掌握。 然后,考虑用户可能遇到的常见问题,比如日志太多难以阅读,或者需要查找特定提交。这时候,介绍一些常用的选项,比如--oneline、--graph、--since等,会有帮助。同时,示例很重要,用户可以通过实际的命令和输出来更好地理解。 还要注意格式问题,用户提到的系统级指令中,要求数学表达式用$...$,但这里可能不太涉及数学内容,所以可能不需要用到。不过要确保中文回答,结构清晰,步骤明确。 另外,用户可能需要知道如何自定义输出格式,比如使用--pretty=format来自定义显示的提交信息,这对定制化需求很有用。还有,如何查看文件的修改历史,比如使用git log <file>,这也是常见的使用场景。 需要检查是否有遗漏的重要选项,比如查看分支合并情况的--graph,或者如何限制显示的提交数量,比如-2。同时,提醒用户可以通过组合不同的选项来达到更精确的查找,比如同时使用--since和--author。 最后,确保语言简洁明了,避免技术术语过多,让不同水平的用户都能理解。可能需要总结常用命令,方便用户快速查阅。还要确认所有命令示例正确,符合LaTeX格式要求,但在这个上下文中可能不需要数学表达式,所以主要关注代码块的正确格式。</think>Git logGit 版本控制系统中用于查看提交历史的命令。通过逐步掌握以下内容,你可以有效追踪项目变更: 一、基础用法 1. 输入 `git log` 会显示完整提交历史 ```bash commit 3a7b8c1d (HEAD -> main) Author: 张三 <zhangsan@example.com> Date: Mon Jan 1 12:00:00 2023 +0800 添加用户登录功能 commit 5d2f4e9a Author: 李四 <lisi@example.com> Date: Sun Dec 31 09:30:00 2022 +0800 初始化项目结构 ``` 二、常用参数(组合使用效果更佳) 1. 精简显示:`git log --oneline` $$3a7b8c1 (HEAD -> main) 添加用户登录功能$$ $$5d2f4e9 初始化项目结构$$ 2. 图形化分支:`git log --graph --decorate` ```bash * commit 3a7b8c1 (main) | Author: 张三 | 添加登录功能 | * commit 5d2f4e9 初始化项目 ``` 3. 过滤提交 - 时间范围:`git log --since="2023-01-01" --until="2023-01-31"` - 按作者:`git log --author="张三"` - 按关键词:`git log -S "login"`(搜索包含"login"的修改) 三、高级应用 1. 查看文件历史:`git log README.md`(追踪特定文件变更) 2. 显示修改内容:`git log -p`(附带代码差异对比) 3. 自定义格式: ```bash git log --pretty=format:"%h | %an | %ad | %s" ``` 输出示例: $$3a7b8c1 | 张三 | Mon Jan 1 12:00:00 2023 +0800 | 添加用户登录功能$$ 四、实用技巧 1. 限制显示数量:`git log -2`(仅显示最新2条记录) 2. 时间线筛选:`git log --after="2 weeks ago"` 3. 组合命令:`git log --oneline --graph --all`(查看全部分支关系) 建议通过 `git help log` 查看完整文档。实际使用时,建议将常用参数设为别名: ```bash git config --global alias.lg "log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset'" ``` 之后通过 `git lg` 即可获得彩色可视化日志。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值