Git:如何通过 .gitignore 忽略隐藏文件/点文件/文件名为空的文件?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11543789/
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
Git: how to ignore hidden files / dot files / files with empty file names via .gitignore?
提问by BerndBrot
These files should all be ignored:
这些文件都应该被忽略:
.weirdBackupFileType
.travis.yml
The following files should not be ignored:
以下文件不应被忽略:
_.weirdBackupFileType
Z.travis.yml
回答by dulvac
If you want to ignore all dotfiles, add this in your .gitignore file (If it doesn't exist, add it)
如果你想忽略所有的点文件,在你的 .gitignore 文件中添加它(如果它不存在,添加它)
.*
!.gitignore
回答by CodeWizard
Your answer is very simple:
你的回答很简单:
This is the content of your .gitignore
file:
这是您.gitignore
文件的内容:
# ignore those files
.weirdBackupFileType
.travis.yml
#DONOT ignore those files (this is what the ! is for - un ignore files)
!_.weirdBackupFileType
!Z.travis.yml
And that's it.
就是这样。
In the image you can see that i have created the file and after adding it to the .gitignore
they are not in the status any more.
在图像中,您可以看到我已经创建了该文件,并且在将其添加到该文件后,.gitignore
它们不再处于该状态。