简体   繁体   English

Git 仍然跟踪 gitignore 文件中的文件

[英]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.

相关问题 Git 子树在 project.gitignore 文件上添加失败(使用 Windows) - Git Subtree add failing on project .gitignore file (using Windows) 如何使git忘记远处的gitignore文件? - How to make git forget about a distant gitignore file? gitignore文件模式不起作用 - gitignore file pattern not working 我可以使用 .gitignore 或 .git/info/exclude 来阻止特定用户拉/推被视为“受限”给他们的文件吗? - Can I use .gitignore or .git/info/exclude to impede specific users from pulling/pushing files that are deemed "restricted" to them? Git 提交,而并行进程仍有处理文件 - Git commit while parallel process still has handle on file 为什么在我的本地仓库中,“git init”会引发致命错误,但仍在创建 .git 文件? 然后,“git status”返回致命错误“不是 git repo”? - Why in my local repo, "git init" throws a fatal error, but is still creating the .git file? Then, "git status" returns fatal error "not a git repo"? Windows .gitignore不忽略Visual Studio临时文件 - windows .gitignore is not ignoreing visual studio temporatry files Git:查找大型包文件中的最大文件 - Git: finding largest files of a large pack file git add hook /让git忽略新文件的文件模式 - git add hook / getting git to ignore file modes of new files Windows 全局 gitignore 不工作...“未跟踪的文件” - Windows global gitignore not working... "Untracked files"
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM