我的存储库中的一个文件让我非常头疼。git status
在“未暂存提交的更改”下将其显示为“已删除”,并且还在“未跟踪的文件”下显示完全相同的文件!该文件肯定存在于我的磁盘上以及远程存储库上。如果我删除该文件,“未跟踪的文件”中的条目就会消失,但另一个条目会保留。
现在我的问题是:这有什么意义?我该如何解决它?
$ git checkout -- .
$ git status
On branch master
Your branch is up-to-date with 'origin/master'.
Changes not staged for commit:
(use "git add/rm ..." to update what will be committed)
(use "git checkout -- ..." to discard changes in working directory)
deleted: solution02/exercise02.txt
Untracked files:
(use "git add ..." to include in what will be committed)
solution02/exercise02.txt
no changes added to commit (use "git add" and/or "git commit -a")
$ git status --short
D "solution02/exercise02.txt "
?? solution02/exercise02.txt
$ rm solution02/exercise02.txt
$ git status
On branch master
Your branch is up-to-date with 'origin/master'.
Changes not staged for commit:
(use "git add/rm ..." to update what will be committed)
(use "git checkout -- ..." to discard changes in working directory)
deleted: solution02/exercise02.txt
no changes added to commit (use "git add" and/or "git commit -a")
$ git status --short
D "solution02/exercise02.txt "
只是澄清一下:第一git status
是一个对我来说没有任何意义的文件,因为它在“未暂存提交的更改”下将该文件列为“已删除”。但该文件并未被删除。它存在。
当文件被巧妙地重命名时,即会发生这种情况。 e.当磁盘上的名称与 Git 存储库中的名称不匹配时,即使两个名称在视觉上是匹配的。例如 :
解决方案是将文件重命名回 Git 名称。精确剪切并粘贴“已删除”的名称可能会有所帮助。
编辑:在命令的实际输出中更新后,结果发现这是第二个选项:“ 后面有一个尾随空格exercise02.txt
" 在 Git 跟踪的文件的名称中。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)