你如何取消外部 git diff? [英] How do you cancel an external git diff?

查看:45
本文介绍了你如何取消外部 git diff?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已将 vim 设置为我的外部差异工具:

[差异]外部 = git_diff_wrapper#!/bin/shvimdiff "$2" "$5"

假设我有 300 个文件被修改;通过 bash,我输入git diff".它依次启动 300 个 vimdiff,我该如何中止它?

解决方案

如果停止进程还不够,终止 shell 本身(您在其中启动了 git diff)可能更有效.

<小时>

另见 Git Diff 与 Vimdiff

<块引用>

还没准备好全速使用 vimdiff(我刚接触它),我将以下内容放入‘gitvimdiff’.
结果是我可以使用 vimdiff 通过运行 'gitvimdiff' 来查看 git-diff,但是正常调用 'git diff'表现得像我习惯的那样.

#!/bin/sh如果 [ -n "${GIT_EXTERNAL_DIFF}" ];然后[ "${GIT_EXTERNAL_DIFF}" = "${0}" ] ||{ echo GIT_EXTERNAL_DIFF 设置为意外值" 1>&2;出口1;}exec vimdiff $2" $5"别的GIT_EXTERNAL_DIFF="${0}" exec git –no-pager diff $@"菲

<小时>

但是如果您仍然想要修改后的 git diff,在启动它之前使用 git status 可能会有所帮助;)

如果需要,您可以设置一个函数来获取旧的 git diff 行为:

<块引用>

我仍然可以使用 --no-ext-diff 标志访问默认的 git diff 行为.这是我放在 bash 配置文件中的一个函数:

function git_diff() {git diff --no-ext-diff -w "$@" |vim -R -}

<块引用>

  • --no-ext-diff:防止使用vimdiff
  • -w:忽略空格
  • -R:以只读模式启动vim
  • -:让vim充当寻呼机

I've got vim setup as my external diff tool:

[diff]
        external = git_diff_wrapper

#!/bin/sh

vimdiff "$2" "$5"

Say I have 300 files that have been modified; via bash, I type "git diff". It launches 300 vimdiffs sequentially, how do I abort it?

解决方案

If stopping the process is not enough, killing the shell itself (in which you launched the git diff) might be more effective.


See also Git Diff with Vimdiff

Not being ready to go full speed into using vimdiff (I’m just new to it), I put the following in ‘gitvimdiff’.
The result is that I can use vimdiff to look at git-diff by running ‘gitvimdiff‘, but a normal invocation of ‘git diff’ behaves as I’m used to.

#!/bin/sh

if [ -n "${GIT_EXTERNAL_DIFF}" ]; then
[ "${GIT_EXTERNAL_DIFF}" = "${0}" ] ||
{ echo "GIT_EXTERNAL_DIFF set to unexpected value" 1>&2; exit 1; }
exec vimdiff "$2″ "$5″
else
GIT_EXTERNAL_DIFF="${0}" exec git –no-pager diff "$@"
fi


But if you still want the modified git diff, a git status might help before launching it ;)

And you can setup a function to get the old git diff behavior if needed:

I still have access to the default git diff behavior with the --no-ext-diff flag. Here’s a function I put in my bash configuration files:

function git_diff() {
  git diff --no-ext-diff -w "$@" | vim -R -
}

  • --no-ext-diff: to prevent using vimdiff
  • -w: to ignore whitespace
  • -R: to start vim in read-only mode
  • -: to make vim act as a pager

这篇关于你如何取消外部 git diff?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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