I added the following line to .gitignore:
.gitignore
sites/default/settings.php
but when I type git status it shows the file
git status
I tried most commands above on VS Code terminal and I got errors like:
fatal: pathspec '[dir]/[file]' did not match any files
I opened the project on GitHub Desktop and ignored from there and it worked.