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

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

问题描述



  [diff] 
external = git_diff_wrapper

#!/ bin / sh

vimdiff$ 2$ 5

假设我有300个已修改的文件;通过bash,我输入git diff。它依次启动300个vimdiffs,如何中止它?解析方案

如果停止进程是不够的,杀死shell本身在其中你启动了 git diff )可能会更有效。 $ b






另见 使用Vimdiff的Git Diff $ b


未准备好全速使用 vimdiff (我刚刚接触它),我把以下内容放在' gitvimdiff '中。

结果是我可以通过运行' gitvimdiff '来使用 vimdiff 来查看git-diff,但是正常的调用' git diff '表现得像我习惯的那样。



 #!/ bin / sh 

if [-n$ {GIT_EXTERNAL_DIFF}];然后
[$ {GIT_EXTERNAL_DIFF}=$ {0}] ||
{echoGIT_EXTERNAL_DIFF设置为意外值1& 2;出口1; }
exec vimdiff$ 2$ 5
else
GIT_EXTERNAL_DIFF =$ {0}exec git -no-pager diff$ @
fi






但是如果你仍然想修改 git diff ,a 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


  • $ <$ c $>
  • - :让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天全站免登陆