Remove and ignore all files that have an extension from a git repository

前端 未结 4 1264
深忆病人
深忆病人 2020-12-23 09:54

I\'m working on a django project with a few other developers and we have recently realized that all the .pwc files in our app cause the commits and repository to be cluttere

4条回答
  •  遥遥无期
    2020-12-23 10:34

    Plenty of ways to remove them:

    git ls-files | grep '\.pwc$' | xargs git rm
    
    find . -name *.pwc | xargs git rm
    

    Note: If you haven't committed them, just use rm, not git rm.

    To ignore them in the future, simply add *.pwc to the .gitignore. (If you don't have one, create a file named .gitignore at the top level of your repository, and just add a single line saying "*.pwc")

提交回复
热议问题