英文:
How can I get rid of additional files to commit after creating a virtual environment in VS Code?
问题
I have cloned a repository from GitHub onto VS Code. I create a virtual environment using
However the moment I do this, I get thousands of files in my source control tab, which I don't want to commit (pictured below). Am I setting up my virtual environment incorrectly? Or is there a way of getting rid of these files from here?
One solution I've read here includes setting up a .gitignore file and writing "node_modules" within it but this doesn't do anything for me. Another was to delete the .git file, this is already in my "files excluded".
英文:
I have cloned a repository from GitHub onto VS Code. I create a virtual environment using
python -m venv myenv
However the moment I do this, I get thousands of files in my source control tab, which I don't want to commit (pictured below). Am I setting up my virtual environment incorrectly? Or is there a way of getting rid of these files from here?
One solution I've read here includes setting up a .gitignore file and writing "node_modules" within it but this doesn't do anything for me. Another was to delete the .git file, this is already in my "files excluded".
答案1
得分: 1
尝试将 /myenv/
放入你的 .gitignore 文件中(或者你的虚拟环境目录的名称)。还可以参考 .gitignore 文档。前导斜杠将相对于 .gitignore 文件进行锚定,尾随斜杠限制了模式应用于目录。如果在这个更改后,在源代码控制视图中立即看不到任何更改,请确保你保存了更改,然后尝试在源代码控制视图中按下刷新按钮。
英文:
Try putting /myenv/
in your .gitignore (or whatever the name of your venv directory is). See also the .gitignore docs. The leading slash anchors relative to the .gitignore file, and the trailing one limits the pattern to apply to directories. If you don't see any changes in the Source Control view immediately after that change, make sure you saved the changes and try pressing the refresh button in the Source Control view.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论