簡體   English   中英

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

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

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM