TransWikia.com

.gitignore doesn't work in windows terminal

Stack Overflow Asked by A100D on February 28, 2021

So i made logs file in this directory :

enter image description here

And then used echo logs/ > .gitignore

After that i used code .gitignore to ignore logs/ in my .gitignore and i’m doing this on new Windows Terminal but i get this when i go to see the status :

enter image description here

Here is the actual content on my .gitignore :

enter image description here

But when i do all of this on Git Bash i get the expected result and if i go to windows terminal after that it somehow got applied to it and now logs/ got ignored.

I don’t know what is wrong with my windows terminal so i would appreciate any help.

2 Answers

@torek Thank you, it had something to do with `utf-8.

I added a few lines in my powershell profile notepad :

[Console]::OutputEncoding = [System.Text.Encoding]::UTF8

$PSDefaultParameterValues['Out-File:Encoding'] = 'utf8'

$PSDefaultParameterValues['Get-Content:Encoding'] = 'utf8'

enter image description here

Then i checked the box for Beta: Use Unicode UTF-8 for worldwide language support :

enter image description here

After rebooting the computer it worked and started to ignore logs/ :

enter image description here

I'm grateful for your help.

Answered by A100D on February 28, 2021

You mention that this does seem to work correctly when using bash as your shell, but not when using some other command-line-interpreter (whatever comes up in "my windows terminal", presumably). Some Windows users have experienced that their command line interpreter writes files using a Windows UTF-16-LE encoding, rather than UTF-8. Git cannot read UTF-16-LE .gitignore file contents as it does not know how to decode UTF-16-LE here. So that's the most likely cause, as bash will not try to re-encode everything intu UTF-16-LE.

Answered by torek on February 28, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP