Gar*_*son 5 windows git git-log
使用 Windows 10 Pro 64 位,我发现了一个很好的命令来列出 Git 历史记录,将HEAD、分支和标签显示为醒目的颜色。好的!
git log --oneline --decorate --graph --all
Run Code Online (Sandbox Code Playgroud)
但我没有看到任何日期或作者!所以我找到了另一个不错的命令:
git log --pretty=format:\"%h %ad | %s%d [%an]\" --graph --date=short
Run Code Online (Sandbox Code Playgroud)
也非常好——现在我可以看到日期和作者。但所有漂亮的颜色都消失了(除了图表)。HEAD、分支和标签的颜色都与日志的其余部分相同,因此很难将它们挑选出来。
如何在保留日期和作者的同时获取提交指针的颜色?
%C(auto)您可以使用和包裹格式字符串%C(reset)以自动为输出着色,如下所示:
%C(auto)<insert your formatting here>%C(reset)
Run Code Online (Sandbox Code Playgroud)
因此,使用您提供的格式:
git log --pretty=format:"%C(auto)%h %ad | %s%d [%an]%C(reset)" --graph --date=short
Run Code Online (Sandbox Code Playgroud)
它将使用 git 的默认颜色来表示分支(远程为红色,本地为绿色,HEAD 为青色等)和提交引用。