Git: how to ignore hidden files / dot files / file

2020-08-09 09:16发布

These files should all be ignored:

.weirdBackupFileType
.travis.yml

The following files should not be ignored:

_.weirdBackupFileType
Z.travis.yml

标签: git gitignore
2条回答
啃猪蹄的小仙女
2楼-- · 2020-08-09 10:05

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

.*
!.gitignore
查看更多
成全新的幸福
3楼-- · 2020-08-09 10:12

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.

enter image description here

查看更多
登录 后发表回答