Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

git - How to ignore only one file without extension?

Tags:

git

gitignore

I wish to ignore only one file without extension. I am able to ignore some files by names, but they all have extensions. Unfortunately I work with some files without extension that should not be ignored; thus, I can not use the solution provided here How do I add files without dots in them (all extension-less files) to the gitignore file?.

Does anybody know a way to achieve this? Any help is appreciated.

like image 437
cyntia Avatar asked Sep 09 '16 10:09

cyntia


2 Answers

You might be making this more complex than it has to be. This could possibly be due to the answer you cited which ignores all extensionless files. To ignore a file without an extension does not appear to be very different than ignoring a file with an extension. To ignore your single file without an extension add this to your .gitignore:

relative/path/to/your/file

If the file had an extension, you would just add this:

relative/path/to/your/file.ext
like image 127
Tim Biegeleisen Avatar answered Oct 06 '22 14:10

Tim Biegeleisen


Based on this Gist https://gist.github.com/chichunchen/970a7e97c74a253a4503

Include the next 3 lines in the beginning of your .gitignore

# Ignore all
*
# Unignore all with extensions
!*.*
# Unignore all dirs
!*/

hope it helps

like image 44
Kevin Oswaldo Avatar answered Oct 06 '22 15:10

Kevin Oswaldo