从git仓库中删除并忽略所有具有扩展名的文件 [英] Remove and ignore all files that have an extension from a git repository

查看:173
本文介绍了从git仓库中删除并忽略所有具有扩展名的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在与其他一些开发人员进行django项目,我们最近意识到应用程序中的所有.pwc文件都会导致提交和存储库混乱。

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 cluttered.

有什么方法可以从git存储库中的所有子目录中删除所有.pwc文件,然后在以后进行任何提交时忽略它们吗?

Is there any way I can remove all .pwc files from all child directories in my git repository and then ignore them for any future commit?

推荐答案

多种删除它们的方法:

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

find . -name *.pwc | xargs git rm

注意:如果尚未提交,请使用 rm ,而不是 git rm

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

要在以后忽略它们,只需添加* .pwc到.gitignore。 (如果没有,则在存储库的顶层创建一个名为.gitignore的文件,然后仅添加一行,写上 * .pwc)。

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")

这篇关于从git仓库中删除并忽略所有具有扩展名的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆