在 git diff 中同时显示暂存树和工作树?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13057457/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Show both staged & working tree in git diff?
提问by swrobel
If I run git diffI see the changes in my working tree, and if I run git diff --staged(alternatively --cached) then I see the changes that are staged (w/ git add) but is there a way with git diffto see all in one go?
如果我运行,git diff我会看到我的工作树中的更改,如果我运行git diff --staged(或者--cached),那么我会看到暂存的更改(w/ git add),但是有没有办法git diff一次性查看所有内容?
采纳答案by VonC
Is there a way with git diff to see all in one go?
有没有办法用 git diff 一次性查看所有内容?
There is, with Git 2.4.0+ (April 2015).
有,使用 Git 2.4.0+(2015 年 4 月)。
See commit 4055500from Michael J Gruber mjg:
commit/status: show the index-worktree diff with-v -v(or-vv)
git commitandgit statusin long format show the diff between HEAD and the index when given-v. This allows previewing a commit to be made.They also list tracked files with unstaged changes, but without a diff.
Introduce '
-v -v' (or-vv) which shows the diff between the index and the worktree in additionto theHEADindex diff. This allows a review of unstaged changes which might be missing from the commit.In the case of '
-v -v' (or-vv), additional header linesChanges to be committed:and
Changes not staged for commit:are inserted before the diffs, which are equal to those in the status part; the latter preceded by 50*
-to make it stick out more.
commit/status: 用-v -v(或-vv)显示索引工作树差异
git commit并git status以长格式显示 HEAD 和给定索引之间的差异-v。这允许预览要进行的提交。他们还列出了具有未暂存更改但没有差异的跟踪文件。
介绍“
-v -v”(或-vv)其示出了索引和worktree之间的差异除了到HEAD索引DIFF。这允许提交中可能缺少的未暂存更改。在“
-v -v”(或-vv)的情况下,附加标题行Changes to be committed:和
Changes not staged for commit:插入差异之前,与状态部分中的差异相同;后者前面有 50*
-以使其更加突出。
In the OP's case, a simple git status -v -v(or git status -vv) will show both staged andunstaged diffs.
在 OP 的情况下,一个简单的git status -v -v(或git status -vv)将显示分阶段和非分阶段的差异。
回答by CB Bailey
If you mean the changes between the working tree and your HEAD commit (i.e. both staged and unstaged changes together) this is just done with:
如果您的意思是工作树和您的 HEAD 提交之间的更改(即暂存和未暂存更改一起),则只需执行以下操作:
git diff HEAD
回答by krlmlr
The diffusevisual diff tool can do that: It will show three panes if some but not all changes are staged. In the case of conflicts, there will even be four panes.
在弥漫可视化差异工具可以做到这一点:它会显示三个窗格如果一些但不是所有的变化都在上演。在发生冲突的情况下,甚至会有四个窗格。


Invoke it with
调用它
diffuse -m
in your Git working copy.
在您的 Git 工作副本中。
If you ask me, the best visual differ I've seen for a decade.
如果你问我,这是我十年来见过的最好的视觉效果。

