如何优化Git log的显示?

Viewed 33

git安装以后使用git log 查看日志如下:

zyz@zyz-rog MINGW64 /d/Code/gitea/WebSocketTool (master)
$ git log
commit aa3482f033f03b570cb72f130ea533fb3e89d3d8 (HEAD -> master, origin/master, origin/HEAD)
Author: DevWiki <devwiki@noreply.localhost>
Date:   Thu Jul 6 19:35:26 2023 +0800

    更新 'README.md'

commit c611622a6337e9f458b2c94ede8fca000ce52225
Author: DevWiki <devwiki@noreply.localhost>
Date:   Thu Jul 6 19:26:31 2023 +0800

    更新 'README.md'

commit 640b568e28cfd14be69bc0816a137ea73522da18
Author: DevWiki <devwiki@noreply.localhost>
Date:   Thu Jul 6 19:18:54 2023 +0800

    更新 'README.md'

commit 87815d5bf62345a65191de7143ee6fab51f660ec (tag: 1.0.2)
Author: DevWiki <devwiki@qq.com>
Date:   Fri Apr 21 18:27:21 2023 +0800

    修改 copyright信息为 2023

commit fdfd1872f4bb9199514219ca73f8a894104435b9
Author: DevWiki <devwiki@qq.com>
Date:   Fri Apr 21 18:07:20 2023 +0800

    修改版本号为 1.0.2
:

image.png

这样看起来很不好看, 如何优化?

1 Answers

可以使用如下设置:

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' --abbrev-commit"

image.png

然后查看效果:

zyz@zyz-rog MINGW64 /d/Code/gitea/WebSocketTool (master)
$ git lg
* aa3482f (HEAD -> master, origin/master, origin/HEAD)更新 'README.md'(3 weeks ago)<DevWiki>
* c611622更新 'README.md'(3 weeks ago)<DevWiki>
* 640b568更新 'README.md'(3 weeks ago)<DevWiki>
* 87815d5 (tag: 1.0.2)修改 copyright信息为 2023(3 months ago)<DevWiki>
* fdfd187修改版本号为 1.0.2(3 months ago)<DevWiki>
* f07832d优化wss链接问题(3 months ago)<DevWiki>
* 1572f31 (tag: v1.0.1)修改版本号(11 months ago)<DevWiki>
* d798e87优化部分设置(11 months ago)<DevWiki>
* 7fd2e91wss 增加tls 版本(1 year, 2 months ago)<DevWiki>
* 994fc8d (tag: v1.0.0)添加异常日志打印(1 year, 4 months ago)<DevWiki>
* 2058b1d修复打包问题(1 year, 4 months ago)<DevWiki>
* a5b6d7fadd README.md.(1 year, 4 months ago)<DevWiki>
* 5f6714efix packege(1 year, 4 months ago)<DevWiki>
* f77a512优化部分错误(1 year, 4 months ago)<DevWiki>
* fcb553b引入 websocket sharp(1 year, 4 months ago)<zhangyazhou>
* 2d0fe5a添加项目依赖(1 year, 5 months ago)<zhangyazhou>
* 2b6de62增加工具类(1 year, 5 months ago)<zhangyazhou>
* e0741d6添加项目文件。(1 year, 5 months ago)<zhangyazhou>
* 89db1af添加 .gitignore 和 .gitattributes。(1 year, 5 months ago)<zhangyazhou>