Reputation: 9558
Is it possible to add some kind of instructions (metasymbols?) to git commit messages, so they will appear colorized in git log
output?
EDIT: I will be more specific — is it possible to mark several words in commit message in different color? I want to embed color marks into commit message and review it via git log
. For instance I would like to have Bug ID appear in red. It is possible to have something like this?
Upvotes: 4
Views: 2405
Reputation: 17077
An answer I haven't found here yet, is that in order to get color codes appear properly in git log
and git diff
, you might also need to specify that the default core.pager
is set to use less
(as in many disto's.) However, less does not channel the color codes right unless you also give less the -r
(raw) option. So you need to do this:
git config --global color.ui true
git config --global core.pager 'less -r'
Upvotes: 0
Reputation: 1268
Check out lines 20 and 21 of my .gitconfig for how I customized git log with colors.
These are my two faviorite git alias that colorize git log.
lg1 = log --graph --all --format=format:'%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C(reset) %C(white)%s%C(reset) %C(bold white)— %an%C(reset)%C(bold yellow)%d%C(reset)' --abbrev-commit --date=relative
lg = log --graph --all --format=format:'%C(bold blue)%h%C(reset) - %C(bold cyan)%aD%C(reset) %C(bold green)(%ar)%C(reset)%C(bold yellow)%d%C(reset)%n'' %C(white)%s%C(reset) %C(bold white)— %an%C(reset)' --abbrev-commit
Upvotes: 1
Reputation: 31467
You could do it manually, e.g. with something like this:
git log --color=always | grep --color=always -C1000 BUG- | less -R
Upvotes: 0
Reputation: 27077
Based on your edit, it appears that you're looking for a way to add formatting to the commit log message itself. I'll answer this by stating that commit messages are stored as plain text within Git Objects. So, theoretically, you could write a program to read and format Git Commit objects using rich text editing, allowing for formatted text, with almost all existing programs you're limited to using plain text.
That being said, you can use the --pretty
option mentioned above in combination with intelligent naming of your commits to make bug IDs stand out.
Upvotes: 2
Reputation: 4664
You can turn on colourised output by setting the git config
option color.ui
to true
. The following should work.
git config --global color.ui true
Then you can define aliases which adds colours using the --pretty=format:".."
option. But I don't think there is any kind of custom matching. I guess that is what you would need to colourise something like bug ID. You can however colourise commit elements like hashes, author, branch, etc.
Upvotes: 3