惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

博客园 - 叶小钗
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Microsoft Security Blog
Microsoft Security Blog
罗磊的独立博客
大猫的无限游戏
大猫的无限游戏
美团技术团队
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
aimingoo的专栏
aimingoo的专栏
腾讯CDC
WordPress大学
WordPress大学
Apple Machine Learning Research
Apple Machine Learning Research
F
Fortinet All Blogs
G
Google Developers Blog
MongoDB | Blog
MongoDB | Blog
Microsoft Azure Blog
Microsoft Azure Blog
小众软件
小众软件
Engineering at Meta
Engineering at Meta
博客园_首页
B
Blog RSS Feed
D
Docker
M
MIT News - Artificial intelligence
爱范儿
爱范儿
I
InfoQ

jdhao's digital space

Conversion between base64 and OpenCV or PIL Image 腾讯云对象存储博客图床开启 CDN 加速(不需要购买额外域名) Search and Replace in Multiple Files in Vim/Neovim Change Table Column Width in LaTeX Image or Table Side by Side in LaTeX LaTeX 并排显示图像或表格 Firenvim: Neovim inside Your Browser Content inside HTML tags missing in Latest Hugo? Creating Markdown Front Matter with Ultisnips Labelme JSON 标注格式转 voc XML 格式 Nifty Nvim Techniques That Make My Life Easier -- Series 6 macOS 下如何为视频制作字幕 Running Command Asynchronously inside Neovim Resolving Merge Conflict after Git Stash Pop Pylint: command not found? A Hands-on Experience with Neovim's Built-in LSP Support How to Convert PDF to Images with Imagemagick 互联网上常用缩略语集锦 File Backup in Neovim Converting PDF Pages to Images with Poppler Nifty Nvim Techniques That Make My Life Easier -- Series 5 Neovim Configuration for System-wide Use How to sort a list of tuple or list in Python -- lambda or itemgetter? Building A Vim Statusline from Scratch 人类第一颗原子弹爆炸始末 Distributed Training in PyTorch with Horovod Learning Expect Programming Essential Knowledge about SSH Nifty LaTeX Techniques -- Series 1 更改 Adsense 邮寄地址,重新寄送 PIN
Better Git log
2021-01-25 · via jdhao's digital space

Some of the settings to make git log better.

Decorate commit#

The --decorate option will show references to your commit. For example, where your HEAD is, where your master points to etc. To use --decorate by default:

git config --global log.decorate true

Show short commit hash#

By default, git shows long commit hash for each commit. To show a short commit hash, we can use the --abbrev-commit option. To use --abbrev-commit by default:

git config --global log.abbrevCommit true

Show commit graph#

To show a graphical representation of commit, which is handy when we have merged commit or multiple branches, we can use --graph option:

Use color and format string for log output#

We can also combine color and % escaped format string to format the log output. Check here for a list of format strings that you can use for log format. Some of most used format string:

  • %h: the abbreviated commit hash
  • %s: the commit message subject
  • %b: the commit message body
  • %d: ref names, like origin/master, origin/HEAD, tag: v0.8
  • %ci: commit date

Use color to differentiate different part of log message. We can specify a color like this %C(red), %Creset will reset the color. For more details on the color format and which colors to use, check color for git pretty format.

Combining the log format string and color, we can create beautiful log message.

git config format.pretty "%C(magenta)%h%Creset -%C(red)%d%Creset %s %C(green)(%cr) %C(cyan)<%an>%Creset"

After this setup, git-log output will be like what is shown in the title image.

References#