Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

.gitignore syntax - how to exclude virtualenv sub-directories?

I have a couple different virtual environments in a project, e.g.

~/project_dir/sub_dirs/venv/...

Adding */venv/* to the .gitignore file does not prevent the virtual environment folders and their contents from being excluded. What is the correct syntax to prevent these virtual environment directories from being added to the git repository?

like image 805
MmmHmm Avatar asked Feb 17 '17 20:02

MmmHmm


People also ask

How do I ignore venv folder?

gitignore folder just add the name of the folder with a slash at the end. This will ignore all sub directories in the venv folder.

Can Gitignore ignore folders?

gitignore is a plain text file in which each line contains a pattern for files or directories to ignore. It uses globbing patterns to match filenames with wildcard characters. If you have files or directories containing a wildcard pattern, you can use a single backslash ( \ ) to escape the character.

Should I add venv to Gitignore?

You should add it to gitignore file. Then, you should create requirements. txt file and populate it with the packages you have installed. Then, on your production server, create the virtual environment and run pip install -r requirements.

Does Gitignore need to be in every folder?

A . gitignore file is a plain text file where each line contains a pattern for files/directories to ignore. Generally, this is placed in the root folder of the repository, and that's what I recommend. However, you can put it in any folder in the repository and you can also have multiple .


1 Answers

per https://github.com/github/gitignore/blob/master/Python.gitignore

venv/ does the trick for sub-directories.

like image 84
MmmHmm Avatar answered Sep 17 '22 14:09

MmmHmm