我正在尝试将 oneline
的 Git 格式设置重新创建为格式字符串(以便进一步扩展)。
所以对于这个命令
git log --format=oneline
oneline
的格式字符串是什么?
我能得到的最接近的是
git log --format="%h %d %s"
但是,这不会产生任何颜色。我知道我可以对其中一些进行硬编码,比如提交哈希。但是 %d 具有动态颜色,具体取决于它显示的内容。
最佳答案
开启自动颜色
git log --format="%C(auto) %h %d %s"
输出看起来像这样
%C(…): color specification, as described in color.branch.* config option; adding auto, at the beginning will emit color only when colors are enabled for log output (by color.diff, color.ui, or --color, and respecting the auto settings of the former if we are going to a terminal). auto alone (i.e. %C(auto)) will turn on auto coloring on the next placeholders until the color is switched again.
关于相当于 oneline 的 Git 漂亮格式字符串,包括颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30551818/