Git 无法解压缩、删除甚至取消跟踪文件

Git 无法解压缩、删除甚至取消跟踪文件,git,atlassian-sourcetree,Git,Atlassian Sourcetree,我最近克隆了一个私有存储库,注意到它已经有一个状态为“已删除”的暂存文件: 发布git status给了我以下信息: Changes to be committed: (use "git reset HEAD <file>..." to unstage) deleted: rootfolder/site/templates/article.php 要提交的更改: (使用“git重置磁头…”取消分级) 删除:rootfolder/site/template

我最近克隆了一个私有存储库,注意到它已经有一个状态为“已删除”的暂存文件:

发布
git status
给了我以下信息:

Changes to be committed:
  (use "git reset HEAD <file>..." to unstage)

        deleted:    rootfolder/site/templates/article.php
要提交的更改:
(使用“git重置磁头…”取消分级)
删除:rootfolder/site/templates/article.php
我想让这个工作目录保持干净,当我取消存储、取消跟踪甚至删除时会出现如下错误:

git-c diff.mnemonicprefix=false-c core.quotepath=false重置-q头 --“rootfolder/site/templates/article.php”

错误:无效路径“rootfolder/site/templates/article.php”致命: 为路径生成\u缓存\u项失败 'rootfolder/site/templates/article.php'


关于如何解决此问题的任何建议,请提前感谢。

对我来说,这是Windows/Linux的事情。我的travis构建(在Linux虚拟机上)在我的代码中运行了一些测试,在
C:/SomeFolder/someTestResult.file
中创建文件。然后,它继续提交这些更改,并推送到
C://
文件夹中的github

当我尝试在windows计算机上进行git克隆时,出现了问题:

$ git clone git@github.com:awesome/somegitrepo.git
Cloning into 'somegitrepo'...
remote: Enumerating objects: 14, done.
remote: Counting objects: 100% (14/14), done.
remote: Compressing objects: 100% (7/7), done.
remote: Total 940 (delta 5), reused 13 (delta 5), pack-reused 926
Receiving objects: 100% (940/940), 500.23 KiB | 364.00 KiB/s, done.
Resolving deltas: 100% (373/373), done.
error: Invalid path 'C:/SomeFolder/someTestResult.file'

显然,由于
C://
文件夹,出现了一些问题。windows上的GIT没有将
C://
视为本地目录,而是将其视为根目录,因此windows GIT repo上没有Linux本地
someTestResult.file
。我猜它当时假设它被删除了,甚至在我做任何更改之前就已经进行了删除


我的解决方案是打开一个Linux终端()并从repo和push中删除文件,以便清理远程存储库

因此,基本上(在WSL中):


我还更改了我的测试以不生成奇怪的目录,并将生成的测试文件放在
.gitignore
中。

试试
git checkout rootfolder/site/templates/article.php
一个新的克隆如何进行任何暂存?Stage是一个本地的东西,而克隆可以与远程存储库一起工作。@YamMarcovic已经这样做了,这也给了我错误
错误:pathspec“rootfolder/site/templates/article.php”与git已知的任何文件都不匹配。
@choroba,是的,这也让我感到惊讶!,我第一次遇到它,但当我第一次克隆它时,它确实有一个已暂存删除的文件。如果您使用Windows或其他具有不区分大小写路径的操作系统,那么在repo中可能有两个文件:rootfolder/site/templates/article.php和rootfolder/site/templates/article.php。签出时,其中一个重写了另一个,这就是您将其视为已删除的原因。我认为除了使用区分大小写路径的操作系统之外,没有其他解决方案。
$ git clone git@github.com:awesome/somegitrepo.git
$ rm -rf C:/
$ git add .
$ git commit -m 'Removed residue test files'
$ git push