git diff 无效的解决

昨天打算把git diff 关联上bcompare作两个文件对比, 后来发现不怎么好用. 还要弹个gtk的窗口. 于是unset了后.

今天重新git diff的时候, 发现输入后没有任何反应. 就记录下怎么修复的

找了一台可以用git diff的机器, 随便echo 了一个多余的字符进已有的repository, 这里我们用strace来追踪执行过程.

#strace -f -e execve git diff
execve("/usr/bin/git", ["git", "diff"], [/* 45 vars */]) = 0
Process 27865 attached
[pid 27865] execve("/usr/lib/git-core/pager", ["pager"], [/* 49 vars */]) = -1 ENOENT (No such file or directory)
[pid 27865] execve("/usr/local/bin/pager", ["pager"], [/* 49 vars */]) = -1 ENOENT (No such file or directory)
[pid 27865] execve("/usr/bin/pager", ["pager"], [/* 49 vars */]) = 0
diff --git a/fabfile.py b/fabfile.py
index e53e07a..0974ee9 100644
--- a/fabfile.py
+++ b/fabfile.py
@@ -176,3 +176,4 @@ def test(version='', by='TAG'):
     _push_rpm(rpmfile=rpmfile)
     # done
     return
+122
[pid 27865] +++ exited with 0 +++
--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=27865, si_uid=1000, si_status=0, si_utime=0, si_stime=0} ---
+++ exited with 0 +++

再看看不能执行的

#strace -f -e execve git diff
execve("/usr/bin/git", ["git", "diff"], [/* 44 vars */]) = 0
Process 20460 attached
[pid 20460] execve("/usr/lib/git-core/less", ["less"], [/* 47 vars */]) = -1 ENOENT (No such file or directory)
[pid 20460] execve("/usr/local/bin/less", ["less"], [/* 47 vars */]) = -1 ENOENT (No such file or directory)
[pid 20460] execve("/usr/bin/less", ["less"], [/* 47 vars */]) = 0
[pid 20460] +++ exited with 0 +++
--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=20460, si_uid=1000, si_status=0, si_utime=0, si_stime=0} ---
+++ exited with 0 +++

原来是正常的pager给换成了less.
这就简单了,找了下/etc/gitconfig. /root/.gitconfig, /home/username/.gitconfig 以及项目下的.git/config 都没有发现alias pager=less的. 看看git config –list 也没有定义.

想起来改过bashrc, 打开一看, 果然

export PAGER=less

删掉后重新加载terminal, git diff就恢复了正常.

你可能感兴趣的:(linux,git,git-diff)