Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

These files should all be ignored:

.weirdBackupFileType
.travis.yml

The following files should not be ignored:

_.weirdBackupFileType
Z.travis.yml
like image 918
BerndBrot Avatar asked Jul 18 '12 14:07

BerndBrot


2 Answers

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

.*
!.gitignore
like image 53
dulvac Avatar answered Oct 02 '22 19:10

dulvac


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

like image 40
CodeWizard Avatar answered Oct 02 '22 19:10

CodeWizard