venv overwrites existing .gitignore
還沒有人認領這個 Issue。
- 主要語言
- Python
- 星號
- 77.2k
- 分支
- 35.9k
- PR 合併指標
- PR 指標待擷取
描述
Bug report
Bug description
I cloned a github project with an existing .gitignore file.
I created a new python venv inside the cloned project using python3 -m venv .venv .
After creating the new venv, I see that the .gitignore file has been modified.
diff --git a/.gitignore b/.gitignore
index d0258704..f514b74c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,17 +1,2 @@
-.dev
-.idea/
-.hypothesis/
-__pycache__/
-db.sqlite3
-*.sw*
-*.pyc
-venv/
-.venv/
-environment_settings.py
-elm-stuff/
-.coverage
-media
-docker/.env
-node_modules
-package-lock.json
-.sass-cache
+# Created by venv; see https://docs.python.org/3/library/venv.html
+*
I found this documentation on the mentioned url added to the .gitignore file:
Changed in version 3.13: venv now creates a .gitignore file for Git by default.
Environment
- Arch linux 6.14.9
- Python 3.13.3
Expected behaviour
I would expect it to not overwrite an existing .gitignore file, so it only creates it if it isnt present already.
Update
Using
python3 -m venv .venvworks as expected, but I didpython3 -m venv .venv .(trailing dot) which creates a folder with a new venv named.venv, but also creates a venv inside the existing folder., and that's when it overwrites the.gitignore
Please let me know if I'm missing some details or you need further testing for triage the issue.
CPython versions tested on:
3.13
Operating systems tested on:
Linux
Linked PRs
- gh-139130
貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
研究方向
在一個已經包含 .gitignore 的專案中使用 python3 -m venv .venv . 重現該行為,然後將其與 python3 -m venv .venv 進行比較。追蹤 python3 -m venv 的進入點,並驗證建立環境不會取代現有的 .gitignore;確認 Python 3.13 中的行為。
由索引模型根據 Issue 內容生成。
評估
- 技術堆疊
- python
- 領域
- tooling
- Issue 類型
- 缺陷
- 難度
- 3/5
- 預估耗時
- 1-2 天
- 活躍度
- 停滯
- 描述清晰度
- 描述清楚
- 新手友好度
- 35/100