如何从Git存储库中删除那些烦人的Mac OS X.DS_Store文件?
当前回答
将此添加到文件中。gitignore
#Ignore folder mac
.DS_Store
保存并提交
git add -A
git commit -m "ignore .DS_Store"
现在你忽略了这一切
其他回答
出于某种原因,以上这些都不适用于我的mac。
我的解决方案来自终端运行:
rm .DS_Store
然后运行以下命令:
git pull origin master
对于那些没有得到上述任何方法帮助的人,请尝试更彻底地检查您的.gitignore,它可能会在目录和子目录之间有一些规则组合,因此烦人的.DS_Store文件不会仅在这些文件夹中被忽略。例如,您希望忽略除自定义目录中的文件夹外的gensrc文件夹,因此可以使用以下.gitignore:
.DS_Store
gensrc
!custom/**
因此,在这个设置中,忽略了任何/path/.DS_Store,而不是自定义/gensrc/.DS_Store,修复程序将把.DS_Store条目移动到.gitignore文件的底部。
如果要将DS_Store文件删除到每个文件夹和子文件夹:如果已提交DS_Store:
find . -name .DS_Store -print0 | xargs -0 git rm --ignore-unmatch
通过以下方式忽略它们:
echo ".DS_Store" >> ~/.gitignore_global
echo "._.DS_Store" >> ~/.gitignore_global
echo "**/.DS_Store" >> ~/.gitignore_global
echo "**/._.DS_Store" >> ~/.gitignore_global
git config --global core.excludesfile ~/.gitignore_global
这将起作用:
find . -name "*.DS_Store" -type f -exec git-rm {} \;
它将删除所有名称以.DS_Store结尾的文件,包括._。DS_存储。
将此添加到文件中。gitignore
#Ignore folder mac
.DS_Store
保存并提交
git add -A
git commit -m "ignore .DS_Store"
现在你忽略了这一切
推荐文章
- “你有邮件”的消息在终端,os X
- 了解Git和GitHub的基础知识
- 没有。Git目录的Git克隆
- Git与Mercurial仓库的互操作性
- 忽略git中修改(但未提交)的文件?
- Mac OS X中的环境变量
- “git restore”命令是什么?“git restore”和“git reset”之间有什么区别?
- Git合并与强制覆盖
- Git拉另一个分支
- 在Bash命令提示符上添加git分支
- 如何更改Git日志日期格式
- 如何从macOS完全卸载蟒蛇
- git pull -rebase和git pull -ff-only之间的区别
- GitHub -致命:无法读取用户名https://github.com':没有这样的文件或目录
- 撤消git平分错误