I have some entries in my .gitignore file in my git repository but some of the entries still show up as untracked files.
The important parts from my .gitignore file:
# IDE settings
.idea/
# Environments
win_venv/
# Byte-compiled / optimized / DLL files
__pycache__/
# Distribution / packaging
*.egg-info/
However, when I run git status, this shows up:
Untracked files:
(use "git add <file>..." to include in what will be committed)
.idea/
mypackage.egg-info/
mypackage/__pycache__/
mypackage/schema/__pycache__/
mypackage/schema/models/__pycache__/
mypackage/tests/__pycache__/
win_venv/
Anyone knows, why this can happen or what the mistakes in my .gitignore file are?
This question is different to the answer suggested, as shown files are not tracked. This issue also happens, if I create a new virtual environment venv, having the appropriate entry in the .gitignore file.
This was a tricky one and another proof, that git works better on Linux. The problem in this very specific case was, that the file encoding was not properly set, so the .gitignore file was handled as a binary file.
Thank you @LeGEC for pointing me into the right direction: I figured out, that something is wicked, when I did a cat .gitignore on a WSL console and the content looked something like this:
I D E s e t t i n g s
. i d e a /
# B y t e - c o m p i l e d / o p t i m i z e d / D L L f i l e s
_ _ p y c a c h e _ _ /
(not an answer, just a list of suggestions to further debug the issue)
Try running git status from different shells : cmd.exe, powershell, git-bash and see if the behavior is the same in all three.
You can also see more information with the following commands :
git status --ignored
git check-ignore -v [paths]
# 'check-ignore' only checks paths explicitly listed on the command line :
git check-ignore -v *
git check-ignore -v .idea mypackage.egg-info mypackage/__pycache__
more details in this question : Git command to show which specific files are ignored by .gitignore
Finally : you can also run git add .idea/ (perhaps choose the folder with the least files ?) and see what gets added.
You can revert that using git reset .idea/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With