我的git-diff刚破了!可能是什么事?
$ sh # start an unmodified shell
sh-4.2$ git --version
git version 2.16.2
sh-4.2$ git status --short
M CMakeLists.txt
?? CMakeLists.txt.bak
sh-4.2$ git diff
sh-4.2$ echo $?
0
sh-4.2$ git add -p
diff --git a/CMakeLists.txt b/CMakeLists.txt
index f527ae0..231dc72 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -101,7 +101,7 @@
actual diff removed
but this is what U'd expect to see
+when doing git diff
some context
and end of diff
Stage this hunk [y,n,q,a,d,/,e,?]? n
好的,让我们试试一个新的存储库
sh-4.2$ git init
Initialized empty Git repository in /tmp/tmp.git/.git/
sh-4.2$ echo 42 > answer
sh-4.2$ git add answer
sh-4.2$ git commit -m"init"
[master (root-commit) 24b402c] init
1 file changed, 1 insertion(+)
create mode 100644 answer
sh-4.2$ echo '7*6' > answer
sh-4.2$ git status --short
M answer
sh-4.2$ git diff
sh-4.2$ git add -p
diff --git a/answer b/answer
index d81cc07..e2d42c8 100644
--- a/answer
+++ b/answer
@@ -1 +1 @@
-42
+7*6
Stage this hunk [y,n,q,a,d,/,e,?]? n
Whaaaat?这可能是麻烦吗?
sh-4.2$ git config --list
filter.lfs.clean=git-lfs clean -- %f
filter.lfs.smudge=git-lfs smudge -- %f
filter.lfs.process=git-lfs filter-process
filter.lfs.required=true
core.symlinks=true
core.autocrlf=false
core.fscache=true
core.pager=less -E
core.editor=emacs
user.name=YSC
user.email=YSC@***
color.diff=auto
color.status=auto
color.branch=auto
color.interactive=true
color.ui=auto
help.format=html
rebase.autosquash=true
alias.st=status -s
alias.l=log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C(reset) %C(black)%s%C(reset) %C(magenta)- %an%C(reset)%C(auto)%d%C(reset)' --all
http.sslverify=false
merge.tool=ediff
mergetool.ediff.trustexitcode=false
mergetool.ediff.cmd=emacs --eval " (progn (defun ediff-write-merge-buffer () (let ((file ediff-merge-store-file)) (set-buffer ediff-buffer-C) (write-region (point-min) (point-max) file) (message \"Merge buffer saved in: %s\" file) (set-buffer-modified-p nil) (sit-for 1))) (setq ediff-quit-hook 'kill-emacs ediff-quit-merge-hook 'ediff-write-merge-buffer) (ediff-merge-files-with-ancestor \"$LOCAL\" \"$REMOTE\" \"$BASE\" nil \"$MERGED\"))"
core.repositoryformatversion=0
core.filemode=true
core.bare=false
core.logallrefupdates=true
答案 0 :(得分:2)
确实,git diff
应该显示您的更改,但有时不会因为错误的寻呼机而导致更改。要检查,请执行:
git --no-pager diff
如果显示某些内容,请将寻呼机设置为简单的内容:
git config --global core.pager less
在您提供的配置中,您的寻呼机是:
core.pager=less -E
根据man less
-E or --QUIT-AT-EOF Causes less to automatically exit the first time it reaches end-of-file.
这意味着如果您的更改小于终端高度,less
会将其分页并在备用屏幕缓冲区打开时立即退出:
在VT102模式下,有一些转义序列用于激活和取消激活备用屏幕缓冲区,该缓冲区的大小与窗口的显示区域相同。激活后,将保存当前屏幕并替换为备用屏幕。在正常屏幕恢复之前,将禁用保存从窗口顶部滚动的行。 xterm的termcap(5)条目允许可视化编辑器vi(1)切换到备用屏幕进行编辑并在退出时恢复屏幕。弹出菜单条目可以在正常和备用屏幕之间切换以进行剪切和粘贴。
(source)
可以使用terminfo(5)
打开/关闭此选项。