bash 为什么 .gitignore 不忽略 .DS_Store?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/32025856/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-18 13:25:58  来源:igfitidea点击:

Why is .gitignore not ignoring .DS_Store?

gitbash

提问by cade galt

In this case I want to ignore the files iOS uses, and in particular this file

在这种情况下,我想忽略 iOS 使用的文件,尤其是这个文件

.DS_Store

I created a .gitignore file as such

我创建了一个 .gitignore 文件

touch .gitignore

and put in a single line

并放入一行

/.DS_Store

I push to a bare repo which has a hook to checkout to a full repo.

我推到一个裸仓库,它有一个钩子可以结帐到完整的仓库。

The file keeps showing up in my full repo.

该文件不断出现在我的完整存储库中。

回答by taylorc93

As you mentioned in your comment, you've already committed the .DS_Storefile. To fix this, just remove the file and make a commit. Then, as long as you have your .gitignorefile set up and stored in your repo, you shouldn't see any more problems with .DS_Storefiles.

正如您在评论中提到的,您已经提交了.DS_Store文件。要解决此问题,只需删除文件并提交即可。然后,只要您.gitignore设置好文件并将其存储在存储库中,您就不会再看到.DS_Store文件有任何问题。

回答by wasddd_

You can also remove committed .DS_Storefiles like this: git rm --cached .DS_Store

您还可以.DS_Store像这样删除提交的文件:git rm --cached .DS_Store