我想知道如何显示对 .gitignore 中的项目所做的更改。 所以说,我有一个包含在.gitignore
中的文件foo.txt
,但我仍然想看看foo.txt
是否已添加到我的本地存储库中,尽管没有提交到它。我怎么能看到这个?
git status
如果new: foo.txt
出现在Changes to be committed
扇区中,则它已被添加但未提交。如果是modified: foo.txt
,则已被跟踪,但尚未提交新版本。如果它未以git status
显示,但显示在git status --ignored
中,则会忽略它并且尚未添加。
git show HEAD:foo.txt
如果它打印文件的内容,则foo.txt
已被跟踪。如果它打印fatal: Path 'foo.txt' exists on disk, but not in 'HEAD'.
,则不会在当前提交中跟踪它。
git check-ignore -v foo.txt
如果它打印忽略foo.txt
的忽略文件,则尚未添加或提交该文件。