I want to share my experience very similar to Visual Studio 2017, although in my case git from the command line was not confirmed by the files listed in my .gitignore .
I used Powershell to create my file .gitignore with the command echo '' > .gitignore . This created a file encoded in UCS-2 LE BOM instead of UTF-8. As a result, git will display the file in git status , but none of the files were not ignored, until I reworked it in UTF-8. So ... be careful when creating an empty file with such a Powershell command as I would like to get into the UTF-16 dungeon.
As mentioned in another answer , I had to use a command like echo '' | Out-File .\.gitignore -encoding Utf8 echo '' | Out-File .\.gitignore -encoding Utf8 Utf8 for the initial creation of a file, even though it creates a file with the UTF-8 specification,
In addition, the following command, as I learned of another answer , copy the contents of the file and creates a new file with only the usual UTF-8 without specification:
Get-Content -Encoding utf8 .\.gitignore.bak | Out-File -Encoding utf8 .\.gitignore
source share