如果我运行git diff
,我将看到工作树中的更改,如果我运行git diff --staged
(或--cached
),那么我将看到已暂存的更改(使用git add
)。但是,在git diff
中是否有一种方法可以一次性查看所有更改?
如果你指的是工作树和你的HEAD提交之间的更改(即已暂存和未暂存的更改),那么只需要执行以下操作:
git diff HEAD
git diff HEAD
显示了在一个 git diff
调用中所有的更改(已暂存和未暂存)。 - CB Bailey有没有一种方法可以使用git diff一次性查看所有内容?
有的,从Git 2.4.0+(2015年4月)开始支持。
请参见提交4055500,作者为Michael J Gruber mjg
。
在OP的情况下,简单的
commit
/status
: show the index-worktree diff with-v -v
(or-vv
)
git commit
andgit 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 theHEAD
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 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.
git status -v -v
(或git status -vv
)将显示已暂存和未暂存的差异。git status -vv
。 - Subfuziondiffuse -m
在您的Git工作副本中。
如果您问我,这是我见过的最好的视觉差异工具。
git diff
的不同类型!https://dev59.com/yHI-5IYBdhLWcg3w99oH#1587952 - swrobelgit status -v -v
将很快显示这个(git 2.3.4+,2015年第二季度)。请参见下面的答案。 - VonC