Remove .pyc files from Git remote repository

前端 未结 10 905
广开言路
广开言路 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:48

    No, you cannot delete them directly from the BitBucket interface but you can delete them in your local checkout and find ./ -type f -name '*.pyc' -exec git rm {} \; ( or simply git rm each pyc file one by one ). Then commit/push your changes.

    Finally, to avoid ever making the same mistake again you may create a file at the root of your repo and name it '.gitignore' with the contents:

    *.pyc
    *~
    *.swp
    

    *~ and ~.swp are other commonly forgotten file types that are often accidentally pushed. See the github doc on gitignore https://help.github.com/articles/ignoring-files (and their repo of .gitignore files for some nice defaults).

提交回复
热议问题