有 git diff 颜色自定义

有 git diff 颜色自定义

如何git diff改变颜色以供某人使用,或者例如diff......?

在~/.gitconfig中:

[color "diff"]
  added = yellow
  changed = red bold

不行。请真诚的帮助表示赞赏

答案1

手册git-config(1)详细说明了可用的插槽;你的addedandchanged可能会像newand一样工作old

   color.diff.<slot>
       Use customized color for diff colorization.  <slot> specifies which
       part of the patch to use the specified color, and is one of context
       (context text - plain is a historical synonym), meta
       (metainformation), frag (hunk header), func (function in hunk
       header), old (removed lines), new (added lines), commit (commit
       headers), whitespace (highlighting whitespace errors), oldMoved
       (deleted lines), newMoved (added lines), oldMovedDimmed,
       oldMovedAlternative, oldMovedAlternativeDimmed, newMovedDimmed,
       newMovedAlternative newMovedAlternativeDimmed (See the <mode>
       setting of --color-moved in git-diff(1) for details),
       contextDimmed, oldDimmed, newDimmed, contextBold, oldBold, and
       newBold (see git-range-diff(1) for details).

相关内容