Git: how to ignore hidden files / dot files / files with empty file names via .gitignore? [duplicate]

佐手、 提交于 2019-12-22 01:58:48

问题


These files should all be ignored:

.weirdBackupFileType
.travis.yml

The following files should not be ignored:

_.weirdBackupFileType
Z.travis.yml

回答1:


If you want to ignore all dotfiles, add this in your .gitignore file (If it doesn't exist, add it)

.*
!.gitignore



回答2:


Your answer is very simple:

This is the content of your .gitignore file:

# 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.



来源:https://stackoverflow.com/questions/11543789/git-how-to-ignore-hidden-files-dot-files-files-with-empty-file-names-via-g

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!