0

作为 Git 的新手,有人可以用相对简单的术语解释一下git diff实际上做了什么,而不涉及分支/合并等吗?

根据我的经验,我知道运行它的结果:我的工作目录中与我的仓库中的文件不同的任何文件都将被返回,git diff只要它们没有被放入暂存索引中。

如果我的所有更改都已放入暂存索引中,git diff则不会返回任何内容。要查看我的更改,我必须使用git diff --staged.

有没有一种简单的方法来解决这个问题?我无法完全理解关于暂存索引的警告。

4

3 回答 3

3

你是对的,git diff显示未分级的更改。

从技术上讲,这是工作树和索引树之间的区别(当没有上演任何内容时,它与 HEAD 的树相同,即最后一次提交)。

git-speak 中的“树”是目录中文件的快照。

于 2013-05-22T13:44:10.723 回答
0

You can read the manual. The "Description" part explains all the variations on git diff, git diff --cached, git diff commit1 commit2, etc...

I would suggedt using git status to have a clear picture of the state of your files.

You can then use git diff HEAD -- <path/to/file> to view the differences between a file in its current state and the last commited version.

于 2013-05-22T14:22:54.013 回答
0

我的建议是阅读这本书(免费提供): http: //git-scm.com/book

于 2013-05-22T13:30:21.227 回答