In my book Python Crash Course 2nd edition it is recommended to put ll_env (venv directory) in .gitignore.
It says, "We tell Git to ignore the entire ll_env directory, because we can re-create it automatically at any time"
But in my opinion this is a very bad move because I won't be able to roll back the installation of packages.
Do I need to do it? Why?
It's good practice not to let git track your venv.
Virtual environments can contain thousands of files and their size can be in gigabytes. Committing them to Git can overload and clutter your source code repo with unnecessary files and cause confusion for anyone trying to clone and run the source code on their machine.
Virtual environments are disposable in nature. They contain packages downloaded from the Internet. They can easily be recreated so there's no need to commit such large files to git.
Virtual environments are re-producible. Django projects ideally comes with a requirements.txt
file that’s created using pip freeze > requirements.txt
. This file shows a list of the installed packages and libraries in your project. You can easily reinstall all the content of the venv folder anywhere you have an internet connection.
See this article for more.