I’ve seen people add a pycache folder in .gitignore.
But never seen adding each __pycache__
folder in each folder of the project tho it feels logical to include every __pycache__
folder to .gitignore like so:
hello_world/__pycache__
pages/__pycache__
(hello_world is the project name and pages is an app name)
Do I need to add all the __pycache__
folders in .gitignore?
Just add
*.py[cod]
into your .gitignore
; that will match all of the files that you’ll (in my experience ever) see in any __pycache__
folder.
This pattern also appears in the GitHub .gitignore template for Python files.
It is good practice to ignore your pycache folders. You can add __pycache__/
to your .gitignore to ignore all pycache folders in your project.