gpt4 book ai didi

git - 如何在 git log 中给文件名上色?

转载 作者:太空狗 更新时间:2023-10-29 14:18:02 25 4
gpt4 key购买 nike

我可以使用 --name-only 选项显示提交中更改的文件。我应该使用什么格式参数才能使此文件列表显示为粗体绿色?

git log --pretty=format:"%ad %Cblue[%an]%Creset %C(red bold)%s%d%Creset %h"--date=short --name-only

最佳答案

您必须使用自己的 git log --pretty=format选项。

--pretty您可以设置颜色并选择您想要显示的任何内容


format:<string>

The format: format allows you to specify which information you want to show. It works a little bit like printf format, with the notable exception that you get a newline with %n instead of \n.

E.g, format:The author of %h was %an, %ar%nThe title was >>%s<<%n would show something like this:

The author of fe6e0ee was Junio C Hamano, 23 hours ago
The title was >>t4119: test autocomputing -p<n> for traditional diff input.<<

The placeholders are:

%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.

%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.

%Cblue: switch color to blue
%Cgreen: switch color to green
%Cred: switch color to red
%Creset: reset color
%D: ref names without the " (", ")" wrapping.
%G?: show "G" for a Good signature, "B" for a Bad signature, "U" for a good, untrusted signature and "N" for no signature
%GG: raw verification message from GPG for a signed commit
%GK: show the key used to sign a signed commit
%GS: show the name of the signer for a signed commit
%H: commit hash
%N: commit notes
%P: parent hashes
%T: tree hash
%aD: author date, RFC2822 style
%aE: author email (respecting .mailmap, see git-shortlog(1) or git-blame(1))
%aI: author date, strict ISO 8601 format
%aN: author name (respecting .mailmap, see git-shortlog(1) or git-blame(1))
%ad: author date (format respects --date= option)
%ae: author email
%ai: author date, ISO 8601-like format
%an: author name
%ar: author date, relative
%at: author date, UNIX timestamp
%b: body
%cD: committer date, RFC2822 style
%cE: committer email (respecting .mailmap, see git-shortlog(1) or git-blame(1))
%cI: committer date, strict ISO 8601 format
%cN: committer name (respecting .mailmap, see git-shortlog(1) or git-blame(1))
%cd: committer date (format respects --date= option)
%ce: committer email
%ci: committer date, ISO 8601-like format
%cn: committer name
%cr: committer date, relative
%ct: committer date, UNIX timestamp
%d: ref names, like the --decorate option of git-log(1)
%e: encoding
%f: sanitized subject line, suitable for a filename
%gD: reflog selector, e.g., refs/stash@{1}
%gE: reflog identity email (respecting .mailmap, see git-shortlog(1) or git-blame(1))
%gN: reflog identity name (respecting .mailmap, see git-shortlog(1) or git-blame(1))
%gd: shortened reflog selector, e.g., stash@{1}
%ge: reflog identity email
%gn: reflog identity name
%gs: reflog subject
%h: abbreviated commit hash
%m: left, right or boundary mark
%n: newline
%p: abbreviated parent hashes
%s: subject
%t: abbreviated tree hash
%w([<w>[,<i1>[,<i2>]]]): switch line wrapping, like the -w option of git-shortlog(1).
%x00: print a byte from a hex code

关于git - 如何在 git log 中给文件名上色?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35594561/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com