如何使用 - 使用git添加色彩词--patch? [英] How to use --color-words with git add --patch?

查看:92
本文介绍了如何使用 - 使用git添加色彩词--patch?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在区分文件时,我更喜欢使用 git diff --color-words 。使用 git add --patch git add --interactive

解决方案

建立VonC所说的话:

使用Git 2.9,你可以使用这个命令在 add --patch 中添加颜色:

  git -c interactive.diffFilter =git diff --color-wordsadd -p 

这会为 add -p 调用设置 interactive.diffFilter 变量,而不会影响其他调用。对我来说这是理想的,因为我通常希望正常运行 add -p ,但有时候想用 - color-words

您可以轻松地为此命令添加别名,如下所示:

  git config --global alias.addcw'-c interactive.diffFilter =git diff --color-wordsadd -p'


When diffing files, I prefer to use git diff --color-words. Is there a way to make this the default format for diffs when using git add --patch or git add --interactive?

解决方案

Building off of what VonC said:

Starting with Git 2.9, you can use this command to color words during add --patch:

git -c interactive.diffFilter="git diff --color-words" add -p

This sets the interactive.diffFilter variable for the call to add -p without affecting further calls. For me this is ideal because I usually want to run add -p normally, but sometimes want to run it with --color-words.

You can easily add an alias for this command like so:

git config --global alias.addcw '-c interactive.diffFilter="git diff --color-words" add -p'

这篇关于如何使用 - 使用git添加色彩词--patch?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆