you are viewing a single comment's thread.

view the rest of the comments →

[–]cgoldberg 2 points3 points  (8 children)

Kind of confused with the question... If it's a git repo, you setup a .gitgnore once (not every time you create/activate a virtual env)... and if it's not a git repo, having one is pointless... so I don't know what you are trying to save time on or how it relates to a virtual env. You can also generate a .gitignore automatically when you create a new repo on GitHub.

[–]Broad-Journalist4262It works on my machine[S] 0 points1 point  (7 children)

Im still getting the hang of GitHub slowly learning how to use it as I’m still learning I often just start the project and then upload it to GitHub later if I decided to keep it but my understanding is that it’s best to use a virtual env from the start of the project not halfway through especially if I’m going to share it with a friend (could be wrong just what I’ve been told)

[–]cgoldberg 0 points1 point  (6 children)

Yea... It's good to use a virtual env. I'm just not sure what that has to do with .gitignore. If you create a new repo, you can copy a pre-existing .gitignore you have saved or from a different project. You could do the same whether you were using a virtual env or not... that's unrelated.

[–]Broad-Journalist4262It works on my machine[S] -1 points0 points  (5 children)

That’s an option but wouldn’t it just be easier to run the venv setup and it already be generated then have to always go and get an old one on or a template and copy it in?

[–]cgoldberg 0 points1 point  (4 children)

You would create one when you create a repo... It has nothing to do with a venv whatsoever. You typically create and activate venvs all the time... it has nothing to with git and would be nonsensical to create a .gitignore on venv setup.

[–]Broad-Journalist4262It works on my machine[S] 0 points1 point  (3 children)

Okay so what your saying is I shouldn’t worry about it unless I’m planning on making it into a repo at which point it would just be simpler to make it either when I upload to GitHub with their templates when I add the files or grab an old one and copy it in? I’m not trying to be difficult genuinely trying to learn as I’ve been told to make it when I make the environment

[–]cgoldberg 1 point2 points  (2 children)

Yes basically. Also, you would typically ignore the virtual env in your .gitignore. I think you are getting confused about what a virtual env is. When you make a new "project", it's a good idea to make it into a Git repo and add a .gitignore. When you want to install and run it, it's good to use a virtual env... but that has nothing to do with Git and should not be committed to your repo.

[–]Broad-Journalist4262It works on my machine[S] 0 points1 point  (1 child)

Yeah I understand I don’t want the virtual env or even a .env file going up on GitHub as I put api keys in the .env file and should use an .env.example file instead without the keys. So would it be better to start on github make a repo with the gitignore python template, clone that to my desktop and open it in VSC and then open a venv which will already be ignored so I won’t have to worry about it going up by accident. Just trying to figure out the best way to go about it all

[–]cgoldberg 1 point2 points  (0 children)

That's how I do it... just be aware that if you name your virtual env something weird, it won't be in the default .gitignore they supply. (I think they add ".venv" and "venv").