git Status显示New和Modified部分中的文件

时间:2013-05-14 22:54:44

标签: git

我在这里发生了一件有趣的事。我已经开发了一段时间(在Windows上开发,文件被移动到Linux VM,提交来自VM)并创建了许多新文件。当我运行git status时,它会在new file:部分和modified:部分显示我的所有新文件。

以下是git status

的结果
# On branch 2.x-merge
# Your branch is ahead of 'composer/2.x-merge' by 1 commit.
#
# Changes to be committed:
#   (use "git reset HEAD <file>..." to unstage)
#
#       new file:   SP/ElasticSearch/ElasticSearch.php
#       new file:   SP/ElasticSearch/Filters/AndFilter.php
#       new file:   SP/ElasticSearch/Filters/Boolean.php
#       new file:   SP/ElasticSearch/Filters/OrFilter.php
#       new file:   SP/ElasticSearch/Queries/Boolean.php
#       new file:   SP/ElasticSearch/Queries/Filtered.php
#       new file:   SP/ElasticSearch/Queries/Match.php
#       new file:   SP/ElasticSearch/Queries/MatchAll.php
#       new file:   SP/ElasticSearch/Queries/Term.php
#       new file:   SP/ElasticSearch/esFilter.php
#       new file:   SP/ElasticSearch/esInserter.php
#       new file:   SP/ElasticSearch/esQuery.php
#       new file:   SP/ElasticSearch/esQueryBuilder.php
#       new file:   tests/SP/ElasticSearch/ESTest.php
#       new file:   tests/SP/ElasticSearch/esFilterTest.php
#       new file:   tests/SP/ElasticSearch/esQueryTest.php
#
# Changes not staged for commit:
#   (use "git add <file>..." to update what will be committed)
#   (use "git checkout -- <file>..." to discard changes in working directory)
#
#       modified:   SP/ElasticSearch/ElasticSearch.php
#       modified:   SP/ElasticSearch/Filters/Boolean.php
#       modified:   SP/ElasticSearch/Filters/OrFilter.php
#       modified:   SP/ElasticSearch/Queries/Boolean.php
#       modified:   SP/ElasticSearch/esFilter.php
#       modified:   SP/ElasticSearch/esQuery.php
#       modified:   SP/ElasticSearch/esQueryBuilder.php
#       modified:   build.xml
#       modified:   tests/SP/ElasticSearch/ESTest.php
#       modified:   tests/SP/ElasticSearch/esQueryTest.php
#

如果您注意到,修改后的部分(build.xml除外)中显示的所有内容都会显示在新部分中,这些都是新文件,因此应该这样做。

提交很顺利,我刚做了一个-am并且没有任何问题,我只是想知道是否有人知道为什么会发生这种情况,它意味着什么,或者它是如何发生的。

提前致谢。

2 个答案:

答案 0 :(得分:2)

请注意两个部分的标题:要提交的更改未提交提交的更改

当您使用git add some_file.txt时,文件的当前状态(在这种情况下为some_file.txt)将被暂存以包含在下一次提交中,因此该文件将出现在更改中已提交列表。如果您在运行git commit之前对该文件进行了进一步更改,则除非您再次运行git add,否则这些更改将不会暂存,因此该文件也会显示在更改未暂存以进行提交< / em> list。

当您运行git commit时,您传递了-a标记(--all的缩写),该标记会自动暂存所有已修改或删除的文件。这相当于在运行git add之前对未提交的提交列表中的所有文件运行git commit

答案 1 :(得分:0)

运行git diff以显示未暂停的更改,并git diff --cached显示已暂存的更改。

您可能在不知不觉中更改了这些文件中的行结尾。 Windows更喜欢2个字节的结束行(回车符和换行符)。 Unix更喜欢1字节的结束行(只是换行符)。