This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: [venv] Adding a .gitignore file to virtual environments
Type: enhancement Stage:
Components: Library (Lib) Versions: Python 3.9
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: Anthony Sottile, brett.cannon, vinay.sajip, xtreak
Priority: low Keywords:

Created on 2020-01-06 19:45 by brett.cannon, last changed 2022-04-11 14:59 by admin.

Messages (2)
msg359459 - (view) Author: Brett Cannon (brett.cannon) * (Python committer) Date: 2020-01-06 19:45
In a discussion on Twitter, the idea of having venv lay down a .gitignore file in a newly created virtual environment that consisted of nothing but `*` came up (https://twitter.com/codewithanthony/status/1213680829530099713). The purpose would be to help prevent people from inadvertently committing their venv to git. It seems pytest does something similar for .pytest_cache (got one complaint but have chosen to keep it otherwise).

To me this seems like a good enhancement. Since this would mostly benefit beginners then it should probably be an opt-out if we do it at all. Maybe make --no-ignore-file to opt out?

FYI Mercurial does not support subdirectory hgignore files like git does, so this may be git-specific (for now): https://www.selenic.com/mercurial/hgignore.5.html.
msg359517 - (view) Author: Vinay Sajip (vinay.sajip) * (Python committer) Date: 2020-01-07 16:32
I'm -0.5 on this. Beginners will probably shoot themselves in the foot multiple ways using git (or any DVCS), in terms of checking things in they didn't mean to (e.g. build artifacts which are not in the venv). As they can easily undo this, I don't think we need to do this.
History
Date User Action Args
2022-04-11 14:59:25adminsetgithub: 83417
2022-02-16 23:42:20brett.cannonlinkissue43275 superseder
2020-01-07 16:32:50vinay.sajipsetmessages: + msg359517
2020-01-07 02:11:43Anthony Sottilesetnosy: + Anthony Sottile
2020-01-06 19:45:32brett.cannonsettitle: Adding a .gitignore file to virtual environments -> [venv] Adding a .gitignore file to virtual environments
2020-01-06 19:45:05brett.cannoncreate