Remove .pyc files from Git remote repository

前端 未结 10 690
广开言路
广开言路 2021-01-30 10:37

Accidentally, I have pushed the .pyc files to the master repository. Now I want to delete them but I can´t do it. Is there any way to remove them directly from the Bitbucket sit

相关标签:
10条回答
  • 2021-01-30 10:59

    This works for me,

    find . -name '*.pyc' | xargs -n 1 git rm --cached
    
    0 讨论(0)
  • 2021-01-30 11:03

    I used simeg's solution but also wanted to deleted tons of *.pyc files added by mistake to a branch. I used awk to delete them from cache recursively.

    git status | awk '{if($1=="modified:" && $2!=".gitignore") ; system("git rm --cached "$2)}'
    

    Then, I deleted the files from my local

    find . -name *.pyc -delete
    
    0 讨论(0)
  • 2021-01-30 11:05

    To remove all .pyc files use git rm -rf *.pyc

    Then add the *.py[co] to your .gitignore file. (This will prevent .pyc and .pyo files from getting committed in the future commits)

    0 讨论(0)
  • 2021-01-30 11:06

    another liner for fun to remove all the pyc files.

    find . -name '*.pyc' -exec git rm {} \;

    don't forget to follow the steps in other answers to commit and add gitignore.

    0 讨论(0)
提交回复
热议问题