Issue
I am using MacOS Monterey 12.3.
Once I initialize git for my Python (Python3.9) project, if I set up virtualenv, all of the sudden, git can no longer track any changes made in the given directory.
To see if initializing git and virtualenv in the same directory causes any issue, I first created a directory "directory_above" and ran git init
there. Then, I created a sub directory "directory_below" in "directory_above", and I set up virtualenv in the sub directory. Even without activating vurtialnenv in the sub directory, git cannot track any changes made in the directory. git status
simply gives me
nothing to commit
As far as I remember, this kind of setup worked fine before, and recently, git started to fail to work with virtualenv.
Has anyone encountered the same issue in the past? If so, how did you solve the issue? I spent some time looking the same issue and solution, but I couldn't find it on here.
Solution
it sounds like you ran virtualenv .
-- but you probably want virtualenv venv
or some other subdirectory
virtualenv
writes a .gitignore
file which contains the following contents:
$ cat venv/.gitignore
# created by virtualenv automatically
*
that *
there will cause all of the contents to be ignored
either delete that file (not recommended) or make your virtualenv in a subdirectory of your project
Answered By - Anthony Sottile Answer Checked By - Clifford M. (WPSolving Volunteer)