有没有办法为git命令默认设置一个标志? [英] Is there any way to set a flag by default for a git command?

查看:113
本文介绍了有没有办法为git命令默认设置一个标志?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

每当我运行 git diff git show 时,我都会自动附加 - 忽略-所有空间。有没有办法做到这一点?我知道我可以创建这样的别名:
$ b


  [别名] 
sh = show --ignore-all-space
di = diff --ignore-all-space


但我想直接使用 diff show 命令。 p>

解决方案

我不这么认为:
$ b


  • 我没有看到git show的 - ignore-all-space 选项


  • 我无法看到自动设置 - ignore-all-space git diff :它必须是作为参数传递。



git diff的一个解决方案至少应该使用 git difftool

由于它是一个脚本(在< git> / libexec / git-core 中),您可以修改那个脚本用这个选项总是设置 git diff



但是,这可能不是一个好主意,因为它可能导致无视cha甚至没有你,发件人有机会检测和测试。


I would like that whenever I run git diff or git show it silently automatically appends --ignore-all-space. Is there a way to do this? I know that I can create aliases like this:

[alias]
   sh = show --ignore-all-space
   di = diff --ignore-all-space

But I would like to use the diff and show commands directly.

解决方案

I do not think so:

  • I do not see any "--ignore-all-space" option for git show

  • I cannot see git diff having the --ignore-all-space set automatically: it has to be passed as argument.

One solution for git diff at least would be to use git difftool.
Since it is a script (in <git>/libexec/git-core), you could modify that script to call git diff with that option always set.

But, that may not prove a good idea, since it can lead to ignore changes that not even you, the sender, had any chance to detect and test.

这篇关于有没有办法为git命令默认设置一个标志?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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