How can I git ignore a specific extension-less file?
I have this file program
(binary, without extension).
I want to ignore it from VCS.
But I cannot put program
directly into .gitignore
because it would ignore my program
folder (which I don't want to git ignore)
Seems like your problem isn't an extension-less file, but rather that you want to ignore a file with a specific name, but allow a folder with the same name.
Solve with this in .gitignore
:
program
!program/
The first line will match any file or folder called program
. The second line will negate the pattern for folders only. The exclamation mark means negation, and the slash at the end means only folders, not files, will be matched. To quote man gitignore
:
An optional prefix "!" which negates the pattern; any matching file excluded by a previous pattern will become included again.
and
If there is a separator at the end of the pattern then the pattern will only match directories, otherwise the pattern can match both files and directories.