2

I'm trying to delete a directory venv (Virtual Environment) from BitBucket repository. I've added an entry for venv/ into .gitignore file but the venv was uploaded during first commit to repository.

In this answer, author says that I have to clean cache.

git rm -r --cached .
git add .
git commit

.

On branch master
Your branch is up-to-date with 'origin/master'.

So I looked into BitBucket account and I still see venv directory and files inside it.

git status --ignored 

returns this:

Ignored files:
  (use "git add -f <file>..." to include in what will be committed)

        venv/Lib/site-packages/pip/_vendor/distlib/t32.exe
        venv/Lib/site-packages/pip/_vendor/distlib/t64.exe
        venv/Lib/site-packages/pip/_vendor/distlib/w32.exe
        venv/Lib/site-packages/pip/_vendor/distlib/w64.exe
        venv/Lib/site-packages/setuptools/cli-32.exe
        venv/Lib/site-packages/setuptools/cli-64.exe
        venv/Lib/site-packages/setuptools/cli-arm-32.exe
        venv/Lib/site-packages/setuptools/cli.exe
        venv/Lib/site-packages/setuptools/gui-32.exe
        venv/Lib/site-packages/setuptools/gui-64.exe
        venv/Lib/site-packages/setuptools/gui-arm-32.exe
        venv/Lib/site-packages/setuptools/gui.exe
        venv/Scripts/django-admin.exe
        venv/Scripts/easy_install-2.7.exe
        venv/Scripts/easy_install.exe
        venv/Scripts/pip.exe
        venv/Scripts/pip2.7.exe
        venv/Scripts/pip2.exe
        venv/Scripts/python.exe
        venv/Scripts/pythonw.exe
        venv/Scripts/wheel.exe

nothing to commit, working directory clean

I've find out that some files are not there. For example django-admin.exe but why there are still other files?

Community
  • 1
  • 1
Milano
  • 18,048
  • 37
  • 153
  • 353
  • 1
    Probably a duplicate of this question: http://stackoverflow.com/questions/20974914/gitignore-doesnt-seem-to-work. Adding a file to .gitignore does not retroactively remove it from the repository. You have to use `git rm --cached` for that. – mkasberg Mar 05 '16 at 16:15
  • Did you push to Bitbucket? – ChrisGPT was on strike Mar 05 '16 at 20:42

1 Answers1

0

You need:

git rm -r --cached venv
echo venv/>.gitignore
git add .
git commit -m "Remove venv tracked content and ignores it"
git push

Then you would not see anymore venv on the remote BitBucket repo.

If your .gitignore was already ignoring the venv/ folder content, check that it is still the case with:

git check-ignore -v -- venv/aFile
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250