git 如何忽略未跟踪文件中的 .DS_Store?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/27317994/
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
How do I ignore .DS_Store in my untracked files?
提问by Eldan Shkolnikov
I am new to Git, and every time I work with it, I always get this annoying .DS_Store
in my untracked files. I am assuming that is where my working directory is.
我是 Git 的新手,每次使用它时,我总是.DS_Store
在未跟踪的文件中遇到这种烦人的问题。我假设那是我的工作目录所在的位置。
I have tried searching the answer on Stack Overflow, but only found the answer on how to remove it from the repository, not from the list of untracked files.
我曾尝试在 Stack Overflow 上搜索答案,但只找到了有关如何从存储库中删除它的答案,而不是从未跟踪的文件列表中。
How can I tell Git to completely ignore .DS_Store
files and never list them as untracked files?
如何告诉 Git 完全忽略.DS_Store
文件并且从不将它们列为未跟踪文件?
回答by Mureinik
You could create a .gitignore
file. This file tells git which file (changes) it should ignore, so they won't appear in git status
, git diff
etc. call.
你可以创建一个.gitignore
文件。该文件会告诉混帐的文件(修改)应该忽略,因此他们将不会出现在git status
,git diff
等电话。
.gitignore
is a simple text file. Just create it in a text editor (or edit it if you already have one), and add this line:
.gitignore
是一个简单的文本文件。只需在文本编辑器中创建它(如果您已经有了,请编辑它),然后添加以下行:
.DS_Store
Then, you should add it to the repository, so these files are ignored by all collaborators:
然后,您应该将其添加到存储库中,以便所有协作者忽略这些文件:
git add .gitignore
git commit -m "added .gitignore"