Saturday, November 13, 2021

[SOLVED] Virtual environment with git

Issue

Recently I found out about the importance of git and therefor started to experiment with it, however I ran into some problems when trying to implement it in a python project on boids. The project directory looks like this:

Boids/
├─ .venv/
│  ├─ ...
├─ .vscode/
│  ├─ ...
├─ __pycache__/
│  ├─ ...
├─ main.py
├─ boid.py

I don't think I want to track everything that happens in the .venv, .vscode and __pycache__ folders through git (right?). Does anyone know how I could arrange this? Also, when uploading the project to GitHub through git Bash, should I include these folders there too? If so, does this work as I guess I would have .gititgnore files in the named folders.

Any help would be appreciated.


Solution

You really should not include those folders because they are dependent on your system and will most likely not work for other people (e.g., Mac vs Windows). Yes, a .gitignore (Note the spelling) is the way to go. There are many examples out there. Often when you create a Git Repo you can select to include one. However, it sounds like you already have a full git configured so it's best to push to an empty GitHub repo. Here's one that I often start with for Python projects: https://github.com/github/gitignore/blob/master/Python.gitignore



Answered By - astrochun