macos系统时常会自动在文件夹中生成.Ds_Store 的隐藏文件,找过各种方法,最后成功了 曾尝试在Apple支持中寻求客服解决 但都无果
.Ds_Store一般不影响正常的使用,甚至在你使用 command+shift+. (打开隐藏文件的快捷键) 都不会看见这个文件,因为苹果对此进行了优化,但是在终端中输入ls -la就会出现,当使用git时,可能刚创建项目时没有,过段时间自动出现
解决方案:
1. 终端中输入如下命令 如果报错 command not found 自行百度安装homebrew (只是个包管理器 对电脑无害 放心安装)
然后输入 brew install vim
vim ~/.gitignore_global
2.复制以下内容至文件内 (按i开始输入,复制完成后 按ese键,输入 :wq) w为保存 q为退出
# Compiled source #
###################
*.com
*.class
*.dll
*.exe
*.o
*.so
# Packages #
############
# it's better to unpack these files and commit the raw source
# git has its own built in compression methods
*.7z
*.dmg
*.gz
*.iso
*.jar
*.rar
*.tar
*.zip
# Logs and databases #
######################
*.log
*.sql
*.sqlite
# OS generated files #
######################
.DS_Store
.DS_Store?
._*
.Spotlight-V100
.Trashes
ehthumbs.db
Thumbs.db
3.在终端中输入如下命令
git config --global core.excludesfile ~/.gitignore_global
4.接着输入
find / -name ".DS_Store" -depth -exec rm {} \;
5.最后输入
defaults write com.apple.desktopservices DSDontWriteNetworkStores true
6.重启mac 会要求输入密码
sudo reboot
如果可行的话,点个赞吧
转载一定一定一定注明出处