Show both staged & working tree in git diff?
如果我运行git diff
我会看到工作树中的更改,如果我运行git diff --staged
(或者--cached
),那么我会看到正在执行的更改(w / git add
),但是有没有办法使用git diff
去看所有在一起?
Is there a way with git diff to see all in one go?
There is, with Git 2.4.0+ (April 2015).
See commit 4055500 from Michael J Gruber mjg
:
commit
/ status
: show the index-worktree diff with -v -v
(or -vv
)
git commit
and git status
in 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 addition to the HEAD
index 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 lines
Changes 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.
In the OP's case, a simple git status -v -v
(or git status -vv
) will show both staged and unstaged diffs.
如果您的意思是工作树和HEAD提交之间的变化(即,一起进行了分阶段和非分阶段更改),则只需完成以下操作:
git diff HEAD
The diffuse visual 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.
If you ask me, the best visual differ I've seen for a decade.
链接地址: http://www.djcxy.com/p/50876.html上一篇: 索引,缓存和在git中上演有什么区别?