Probably a repeat, but I can't find an answer.
So I have a .gitignore
file:
transactions.csv
transactions_test.csv
**/test.gnucash*
test
**/test.gnucash.2*
And the following directory:
LICENSE test.gnucash transactions_test.csv
main.py test.gnucash.20180615182021.gnucash transactions_testPUBLIC.csv
README.md test.gnucash.20180618121545.gnucash translations.json
test/ transactions.csv
However when I run git ls-tree -r master --name-only
I get:
.gitignore
.vscode/settings.json
LICENSE
README.md
main.py
test.gnucash.20180615182021.gnucash
test.gnucash.20180618121545.gnucash
transactions_testPUBLIC.csv
translations.json
Even weirder than that, if I run this through a glob tester, it works correctly. (see hyperlink)
Any ideas as to what's happening? I'm running Git for Windows on Windows 10.
$ git --version
git version 2.17.0.windows.1
You have already added these files to git, haven't you? .gitignore
does not affect files already known to git; it only excludes untracked files from consideration for addition.
So if you don't want to see a file, you first need to remove it from being tracked with git rm --cached [FILE TO BE REMOVED]
(where --cached
will prevent git from actually deleting files). As noted by @Bo-G, this will not completely remove a file from a repository's history; it will still be part of earlier revisions or other branches.