简体   繁体   English

git突出显示提交消息

[英]git highlighting of commit message

Is it possible to make git commands highlight a commit message in the terminal? 是否有可能使git命令突出显示终端中的提交消息?

For example: 例如:

$git stash $ git stash

Saved working directory and index state WIP on master: 9d657ff Sort events 主服务器上已保存的工作目录和索引状态WIP:9d657ff 对事件进行排序

HEAD is now at 9d657ff Sort events HEAD现在是9d657ff 排序赛事

Otherwise it is hard to catch them in the abundant output of git. 否则很难在丰富的git输出中捕获它们。

Adding --color works for several git commands... but not for that specific one ( git stash ), and they highlight the commit hash, not the commit message. 添加--color适用于几个git命令...但不适用于那个特定的命令( git stash ),它们突出显示提交哈希,而不是提交消息。

git stash list is supposed to take the same options as git log (which includes --color ), but I had to specify some format (eg --oneline ) to get it to work: git stash list应该采用与git log (包括--color )相同的选项,但我必须指定一些格式(例如--oneline )才能使它工作:

git stash list --oneline --color

Also, git has a config option to use color in all commands by default ( color.ui , in git help config )... but, like the above, it works for some commands, but not that one. 此外,git有一个配置选项,默认情况下在所有命令中使用颜色( color.ui ,在git help config )...但是,如上所述,它适用于某些命令,但不适用于那些命令。

Finally, git log enables you to specify precisely what colors you want in the formatting, and since many commands use git log and accept options for it, you could highlight the commit message in that way, for those commands (and make aliases for them). 最后,使用git log可以精确指定格式化中需要的颜色,并且由于许多命令使用git log并接受选项,因此可以以这种方式突出显示提交消息,并为这些命令创建别名(并为它们创建别名) 。

FWIW I agree it would be a good feature. FWIW我同意这将是一个很好的功能。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM