0

I'm trying to exclude the pycache directory with these lines:

aws_scripts/python/aws_tools/__pycache__/
*.pyc

I can list that directory from my current location:

ls .\aws_scripts\python\aws_tools\__pycache__\

    Directory: C:\Users\bluet\OneDrive\Desktop\important_folders\Jokefire\git\jf_cloud_scripts\aws_scripts\python\aws_tools\__pycache__

Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
la---           5/16/2021 10:47 PM            763 aws_add_sg_list.cpython-39.pyc
la---           5/16/2021 10:47 PM           1173 aws_tag_resources.cpython-39.pyc
la---           5/16/2021 10:47 PM            894 banners.cpython-39.pyc
la---           5/16/2021 10:47 PM           1148 choose_accounts.cpython-39.pyc
la---            5/4/2021  8:10 AM          12871 ec2_mongo.cpython-38.pyc
la---           5/15/2021 10:01 AM          15714 ec2_mongo.cpython-39.pyc
la---           5/16/2021 10:47 PM            811 find_vpcs.cpython-39.pyc
la---           5/16/2021 10:47 PM           1183 init.cpython-39.pyc
la---           5/16/2021 10:47 PM            848 list_new_instances.cpython-39.pyc 
la---           5/16/2021 10:47 PM            937 modules.cpython-39.pyc
la---           5/16/2021 10:47 PM            665 read_account_info.cpython-39.pyc  
la---           5/16/2021 10:47 PM           6764 user_input.cpython-39.pyc

Yet, when I do a git status it still shows me the __pycache__ directory:

git status        
On branch develop
Your branch is up to date with 'origin/develop'.

Changes to be committed:
  (use "git restore --staged <file>..." to unstage)
        deleted:    aws_scripts/python/aws_tools/.gitignore

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
        modified:   .gitignore
        modified:   aws_scripts/python/aws_tools/__pycache__/ec2_mongo.cpython-39.pyc

What am I doing wrong?

phd
  • 82,685
  • 13
  • 120
  • 165
bluethundr
  • 1,005
  • 17
  • 68
  • 141

1 Answers1

0

add this to your .gitignore file __pycache__/

EDIT:

It is because you have already added it to the staging area. Try this:

git rm --cached -r __pycache__

Ayush Gupta
  • 1,166
  • 2
  • 9
  • 25
  • I tried that too. This is my entire `.gitignore` file: ```*.pyc __pycache__/ .vscode/ aws_scripts/output_files/ aws_scripts/source_files/``` – bluethundr May 29 '21 at 20:33
  • Yet when do a git status the `__pycache__` directory is still there: ```git status On branch develop Your branch is ahead of 'origin/develop' by 1 commit. (use "git push" to publish your local commits) Changes not staged for commit: (use "git add ..." to update what will be committed) (use "git restore ..." to discard changes in working directory) modified: .gitignore modified: aws_scripts/python/aws_tools/__pycache__/ec2_mongo.cpython-39.pyc``` – bluethundr May 29 '21 at 20:33
  • I have made the edit. It should work now – Ayush Gupta May 29 '21 at 20:39