Reputation: 4128
works-as-designed
Similar: 35735862/gitignore-difficulty-with-folder-exclusion-being-ignored
I'd like git add .
to not result in my file being tracked.
git version 2.24.1.windows.2` using Windows PowerShell on Windows 10.
My file is mysf.txt
(my_secret_file).
./gitignore
contains: mysf.txt
, but I've also tried absolute paths and .\mysf.txt
to no effect.
git add . > git status
reports that mysf.txt being tracked.
git rm --cached mysf.txt > git commit > git status
reports that the file is "untracked".
So, I deleted mysf.txt and made a new file called secret_file.txt
.
Now, I've ensured that the text, secret_file.txt
, is added to .gitignore
before doing the following:
git add .
git echo "this file is to be ignored." > secret_file.txt
git commit
git status
secret_file.txt is not tracked. Now, I type git add .
and secret_file.txt is tracked!
Upvotes: 1
Views: 67
Reputation: 4128
Change the encoding of .gitignore to utf-8.
This can be accomplished in a number of ways. Notepad++ has a drop-down menu called 'encoding'; notepad has encoding options in its save-as dialog; linux subsystem's touch
command can be used rather than batch's echo
command to create files via commandline.
Converting a file to utf-8: Get-Content .\test.txt | Set-Content -Encoding utf8 test-utf8.txt
thanks to post by DavidPostill.
Set-Content <filename> -Encoding <Encoding>
For example: Set-Content my_file.txt -Encoding utf8
(*1).
*1. Please note: case-sensitive!
Upvotes: 1