5

I am merely a hobbyist programmer, but my projects are becoming more complex and so I wanted to use a Version Control System. GIT seemed the obvious choice. I also wanted a more sophisticated IDE - and one that integrated with GIT / Github, so I chose Pycharm.

In my first few test projects all was well. I could commit changes and push them to my GIThub and then pull them from another computer and have a synchronised project.

I understand the benefit of a Virtual Environment (although for my small project it seems unnecessary) but I am a little confused about where Pycharm seems to want to put the files. Moreover, now when I do a push to Github the Venv folder is uploaded too. I can't see why I would want venv in my Github repository (or should I?), so I added it to my .gitignore

/venv/
/MyProject/venv/
PycharmProjects/MyProject/venv/

and yet it's still there, and still getting updated. I tried removing it at the command line:

$ git rm -r venv/

and that messed up my environment in Pycharm (even though the actual directory was still present).

What am I doing wrong - and how do i fix it?

Many thanks!

ArthurDent
  • 149
  • 2
  • 10

1 Answers1

7

You are right, usually you want to keep the repository clean of ide and venv specific files. The problem was, that you removed the folder from the working tree. So it is not just removed from git, it is deleted. Use this to rollback your deletion.

To remove a file or directory just from the git index, you may use

git rm -r --cached venv/

After that you can commit the changes, venv should now be untracked.

For more detail I recommend This tutorial

e.Fro
  • 387
  • 1
  • 14
  • Thank you @e.Fro! That's brilliant! The tutorial you linked was especially helpful (and not one that I managed to find when I googled this problem - I guess I need to improve my googling skills as well as my Github skills!). I have cleaned up my development branch. I now need to take a deep breath and merge it with the master... Thanks again! – ArthurDent Jul 12 '20 at 12:46