如何 git 忽略特定的无扩展名文件
How to git ignore a specific extension-less file
如何git忽略特定的无扩展名文件?
我有这个文件 program
(二进制文件,没有扩展名)。
我想从 VCS 中忽略它。
但我不能将 program
直接放入 .gitignore
,因为它会忽略我的 program
文件夹(我不想 git 忽略它)
您的问题似乎不是 extension-less 文件,而是您想忽略具有特定名称的文件,但允许具有相同名称的文件夹。
在.gitignore
中解决这个问题:
program
!program/
第一行将匹配任何名为 program
的文件或文件夹。第二行将仅否定文件夹的模式。感叹号表示否定,最后的斜杠表示只匹配文件夹,不匹配文件。引用 man gitignore
:
An optional prefix "!" which negates the pattern; any matching file excluded by a previous pattern will become included again.
和
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.
如何git忽略特定的无扩展名文件?
我有这个文件 program
(二进制文件,没有扩展名)。
我想从 VCS 中忽略它。
但我不能将 program
直接放入 .gitignore
,因为它会忽略我的 program
文件夹(我不想 git 忽略它)
您的问题似乎不是 extension-less 文件,而是您想忽略具有特定名称的文件,但允许具有相同名称的文件夹。
在.gitignore
中解决这个问题:
program
!program/
第一行将匹配任何名为 program
的文件或文件夹。第二行将仅否定文件夹的模式。感叹号表示否定,最后的斜杠表示只匹配文件夹,不匹配文件。引用 man gitignore
:
An optional prefix "!" which negates the pattern; any matching file excluded by a previous pattern will become included again.
和
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.