Reputation:
When I run git add .
it is adding all the files in the directory, even I specified it in .gitignore
to ignore the specific folder and files. In this case it is the __venv__
and __pycache
. The .gitignore
file is created and directories to ignore is specified before the git repository is initiated. I deleted the git
folder and reinitiated the repository several time from the root directory of the project but it still do not ignore the declarations in the .gitignore
file. On Windows, deleting and reinitiating the repository fixes the problem but on Linux it doesn't
Update: Adding the directory to be excluded to .git/info/exclude works but when adding it to .gitignore it doesn't
Upvotes: 2
Views: 222
Reputation: 1324318
The rule to add in a .gitignore should be:
__venv__/
__pycache/
# or
__pycache__/
(see https://www.gitignore.io/api/python)
Note the trailing '/
'
I just realized that my text editor for some reason append a space in front of the declarations automatically.
I found that out after clearing the file and rewrite it again
That would explain why a .gitignore
rule is not applied indeed.
If the files within those two folders were not already tracked, they won't be added.
If not:
git rm --cached -r __venv__/
Upvotes: 3