我已经将.DS_Store添加到.gitignore文件中,但它似乎只是忽略了根目录中的.DS_Store,而不是每个文件夹和子文件夹中的.DS-Store。
我该如何修复?
我已经将.DS_Store添加到.gitignore文件中,但它似乎只是忽略了根目录中的.DS_Store,而不是每个文件夹和子文件夹中的.DS-Store。
我该如何修复?
当前回答
步骤:1)使用此命令删除现有文件
查找-name.DS_Store-print0|xargs-0 git rm-f--忽略取消匹配
步骤:2)在.gitignore文件中添加.DS_Store
步骤:3)在.gitignore中提交更改git-add.gitignoregitcommit-m“已删除.DS_Store”
其他回答
.gitignore文件应如下所示:
# Ignore Mac DS_Store files
.DS_Store
只要不包含斜线,它将与所有目录中的文件名匹配。(从这里开始)
将*.DS_Store添加到.gitignore文件中。这对我来说很好
步骤1,删除所有*.DS_store文件。一个人可以跑
git rm -f *.DS_Store
但是要注意,如果你有拼写错误,rm-f可能会有点危险!第二步:添加
*.DS_Store
.DS_Store
到。gitignore。这对我有用!
将子目录的**/.DS_Store添加到.gitignore中
如果.DS_Store已提交:
find . -name .DS_Store -print0 | xargs -0 git rm --ignore-unmatch
在所有存储库中忽略它们:(有时名为._.DS_Store)
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
如果.DS_Store从未添加到git存储库中,只需将其添加到.gitignore文件中即可。
如果没有,请创建一个名为
.gitignore
在应用程序的根目录中,只需编写
**/.DS_Store
这将永远不会允许.DS_Store文件潜入您的git中。
但是,如果它已经存在,请在终端中写入:
find . -name .DS_Store -print0 | xargs -0 git rm -f --ignore-unmatch
然后提交并推送更改以从远程存储库中删除.DS_Store:
git commit -m "Remove .DS_Store from everywhere"
git push origin master
现在将.DS_Store添加到.gitignore文件中,然后再次提交并推送最后两段代码(gitcommit…,gitpush…)