Any time I see a .gitignore
file in a Git repository, I can't help but notice that, aside from the file extension, the filename is completely empty. Because of this, I've often seen new programmers run into the "You must enter a filename" error on Windows when learning Git for the first time.
Other standard files such as README.md
include basenames, so it seems odd to exclude the name for .gitignore
.
Is there a reason .gitignore
's basename is always empty? Would the file still work properly if it were given a filename like project-name.gitignore
?
As stated by others in the comments, a dot in front of a filename implies a hidden file in unix/linux systems.
Would the file still work properly if it were given a filename like project-name.gitignore?
No, it would not. Git only looks for file named .gitignore
(plus your global ignore file defined in config).
Other standard files such as README.md include basenames, so it seems odd to exclude the name for .gitignore.
README.md is not a standard file in Git, it is something that many hosting providers use. Standard git files such as .gitignore
and .gitattributes
have a consistent naming convention.