[英]Git Subtree add failing on project .gitignore file (using Windows)
[英]Git still tracks files in gitignore file
我在 Windows 中使用 gitignore 遇到以下问题(如果此信息很重要,我将其与 vscode 结合使用)
我尝试了一个简单的例子,以免使事情复杂化。
我的根文件夹包含:
maininterface.py
.gitignore
logs/dev.log
我的 gitignore 文件只有一行:
logs/
输入 git status 时,我得到以下信息:
Untracked files:
(use "git add <file>..." to include in what will be committed)
.gitignore
logs/
maininterface.py
我错过了什么吗? 目录日志不应位于未跟踪的文件中。
我尝试寻找解决方案,很多人建议git rm --cached logs
这对我不起作用,我得到:
fatal: pathspec 'logs' did not match any files
(我也试过git rm --cached logs/dev.log
,同样的问题)
顺便说一句,我没有在任何文件上使用 git add 。
如有指点,谢谢...
检查您的.gitignore
文件是否没有寄生字符。
例如:文件开头的 BOM 会使 git 尝试查找"{\\xEF\\xBB\\xBF}logs"
。
[编辑]:默认情况下,我忘记了UTF-16
(或UCS-2
)中的 powershell 写入,您正确地发现,在 BOM 之上,您的文件实际上是在UCS-2
编码的。
问题解决了。 使用记事本++,这是编码问题...!
非常感谢你的帮助
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.