简体   繁体   中英

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)

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:

logs/

when typing git status i get the following:

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 :

fatal: pathspec 'logs' did not match any files 

(I also tried git rm --cached logs/dev.log , same problem)

BTW I haven't used git add on any of the files.

Thank you if you have a tip...

Check if your .gitignore file is free of parasite characters.

For example : a BOM at the beginning of the file would make git try to look for "{\\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 .

Problem solved. with Notepad ++, it was the encoding issue...!

Thank you very much for the help

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM