[英]Git still tracks files in gitignore file
i am having the following problem with gitignore in windows (that i used in combination with vscode, if this info is important)我在 Windows 中使用 gitignore 遇到以下问题(如果此信息很重要,我将其与 vscode 结合使用)
i tried a simple example in order not to complicate things.我尝试了一个简单的例子,以免使事情复杂化。
my root folder contains:我的根文件夹包含:
maininterface.py
.gitignore
logs/dev.log
my gitignore file has only one line:我的 gitignore 文件只有一行:
logs/
when typing git status i get the following:输入 git status 时,我得到以下信息:
Untracked files:
(use "git add <file>..." to include in what will be committed)
.gitignore
logs/
maininterface.py
Am I missing something?我错过了什么吗? the directory logs should not be in the untracked files.目录日志不应位于未跟踪的文件中。
I tried looking for solutions, many people suggest git rm --cached logs
This does not work for me, I get :我尝试寻找解决方案,很多人建议git rm --cached logs
这对我不起作用,我得到:
fatal: pathspec 'logs' did not match any files
(I also tried git rm --cached logs/dev.log
, same problem) (我也试过git rm --cached logs/dev.log
,同样的问题)
BTW I haven't used git add on any of the files.顺便说一句,我没有在任何文件上使用 git add 。
Thank you if you have a tip...如有指点,谢谢...
Check if your .gitignore
file is free of parasite characters.检查您的.gitignore
文件是否没有寄生字符。
For example : a BOM at the beginning of the file would make git try to look for "{\\xEF\\xBB\\xBF}logs"
.例如:文件开头的 BOM 会使 git 尝试查找"{\\xEF\\xBB\\xBF}logs"
。
[edit] : I had forgotten powershell writes in UTF-16
(or UCS-2
) by default, you correctly found that, on top of a BOM, your file was actually encoded in UCS-2
. [编辑]:默认情况下,我忘记了UTF-16
(或UCS-2
)中的 powershell 写入,您正确地发现,在 BOM 之上,您的文件实际上是在UCS-2
编码的。
Problem solved.问题解决了。 with Notepad ++, it was the encoding issue...!使用记事本++,这是编码问题...!
Thank you very much for the help非常感谢你的帮助
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.