如何在创建虚拟环境后,在VS Code中摆脱需要提交的额外文件?

huangapple go评论61阅读模式
英文:

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".

如何在创建虚拟环境后,在VS Code中摆脱需要提交的额外文件?

英文:

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".

如何在创建虚拟环境后,在VS Code中摆脱需要提交的额外文件?

答案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.

huangapple
  • 本文由 发表于 2023年4月19日 23:43:05
  • 转载请务必保留本文链接:https://go.coder-hub.com/76056445.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定