如何从 Git 存储库中删除 .DS_Store 文件? [英] How can I Remove .DS_Store files from a Git repository?

查看:40
本文介绍了如何从 Git 存储库中删除 .DS_Store 文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何从 Git 存储库中删除那些烦人的 Mac OS X .DS_Store 文件?

How can I remove those annoying Mac OS X .DS_Store files from a Git repository?

推荐答案

从存储库中删除现有文件:

Remove existing files from the repository:

find . -name .DS_Store -print0 | xargs -0 git rm -f --ignore-unmatch

添加这一行:

.DS_Store

到文件 .gitignore,它可以在您的存储库的顶层找到(或者如果文件不存在,则创建该文件).您可以在顶级目录中使用此命令轻松完成此操作:

to the file .gitignore, which can be found at the top level of your repository (or create the file if it isn't there already). You can do this easily with this command in the top directory:

echo .DS_Store >> .gitignore

然后将文件提交到仓库:

Then commit the file to the repo:

git add .gitignore
git commit -m '.DS_Store banished!'

这篇关于如何从 Git 存储库中删除 .DS_Store 文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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