[英]Untracked ignored files still appear in git status
我知道也有类似的问题,但是这些解决方案都不适合我,因此提出了一个新问题。
我有以下.gitignore
部分:
#generated sources in tfliteparser/tflite
tfliteparser/tflite/
kernels/native_funcs.cpp
但是,当我运行git status
,文件和文件夹都出现在“未跟踪的文件”部分中:
Untracked files:
(use "git add <file>..." to include in what will be committed)
../.DS_Store
kernels/native_funcs.cpp
network_summary.dat
tfliteparser/tflite/
我假设,由于这些对象位于未跟踪部分中,因此它们从未添加到索引中,对吧? 为什么它们会出现?
我试过的
git rm --cached kernels/native_funcs.cpp
这给出:
fatal: pathspec 'kernels/native_funcs.cpp' did not match any files
但是,该文件在那里。 如果我将其ls
,操作系统将看到它。 我也试过了 。 结果相同。
我知道一个事实, .gitignore
文件会被加载,因为如果我向它添加network_summary.dat
文件,它将被忽略。
有什么想法吗?
通过../.DS_Store
我看到当前目录不是存储库的根目录。 您的忽略模式包含斜杠,因此它们仅在.gitignore
所在的目录级别匹配。 如果.gitignore
位于存储库的根目录,则您的模式不匹配。
要使它们匹配,请在子目录名称前加上星号或在它们前面加上前缀:
# .gitignore
<subdir>/tfliteparser/tflite/
*/kernels/native_funcs.cpp
$ git rm --cached kernels/native_funcs.cpp
fatal: pathspec 'kernels/native_funcs.cpp' did not match any files
这意味着kernels/native_funcs.cpp
不在索引中(文件不是git add
ed)。 git rm --cached
仅从索引中删除,而不从文件中删除。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.