如何将不带点的文件(所有无扩展名的文件)添加到 gitignore 文件? [英] How do I add files without dots in them (all extension-less files) to the gitignore file?
问题描述
如标题所说,是否可以在 gitignore 文件中添加没有点的文件"?
我想这会处理所有那些麻烦的无扩展文件.
你可以尝试类似的组合:
<预><代码>*!/**/!*.*那个 gitignore
排除规则(一个 否定模式) 应忽略所有文件,但带有扩展名的文件除外.
如下文所述,Mad Physicist,规则是:
如果排除文件的父目录,则无法重新包含该文件. (*
)
(*
:除非在 git 2.?+ 中满足某些条件,见下文)
如果我们想将文件列入白名单,这就是为什么 !/**/
很重要(递归地将父文件夹列入白名单).
我在类似的情况下提到了相同的规则,例如:
<小时>作为 Jakub Narębski 评论,您可能不想忽略所有 无扩展名的文件.
我的建议:
- 首先添加重要的无扩展名文件
- 然后编辑您的
.gitignore
如上所示:不会忽略已经版本化的文件(即使它们没有扩展名).所有其他人都将被忽略.
对于您希望版本化的任何未来无扩展文件:
git add -f -- myFile
<小时>
请注意,对于 git 2.9.x/2.10(2016 年中期?),如果排除了该文件的父目录,则可能会重新包含该文件 如果路径中没有-included> re.
Nguyễn Thái Ngọc Duy (pclouds
) 正在尝试添加此功能:
- 提交 506d8f1 用于 git v2.7.0,在 commit 76b620d git v2.8.0-rc0
- commit 5e57f9c git v2.8.0-rc0,...恢复(!)在 commit 5cee3493 git 2.8.0-rc4 中.
但是,由于重新包含的规则之一是:
<块引用>重新包含规则中的目录部分必须是文字(即没有通配符)
无论如何这都行不通.
Like the title says, is it possible to add "files without dots in them" to the gitignore file?
I imagine this would take care of all those bothersome extensionless files.
You can try a combination similar to:
*
!/**/
!*.*
That gitignore
exclusion rule (a negated pattern) should ignore all files, except the ones with an extension.
As mentioned below by Mad Physicist, the rule is:
It is not possible to re-include a file if a parent directory of that file is excluded. (*
)
(*
: unless certain conditions are met in git 2.?+, see below)
That is why !/**/
is important (white-listing the parent folders recursively) if we want to white-list files.
I mentioned that same rule in similar cases like:
- Gitignore all except one folder and all its content - regardless of the nesting level
- Git except a sub directory and it's files of a ignored directory
- Gitignore exclude certain files in all subdirectories
As Jakub Narębski comments, you might not want to ignore all extensionless files.
My advice:
- add first the extensionless file that matters
- then edit your
.gitignore
as shown above: the already versioned files won't be ignored (even if they don't have an extension). All the others will be ignored.
For any future extensionless files that you would want to version:
git add -f -- myFile
Note that with git 2.9.x/2.10 (mid 2016?), it might be possible to re-include a file if a parent directory of that file is excluded if there is no wildcard in the path re-included.
Nguyễn Thái Ngọc Duy (pclouds
) is trying to add this feature:
- commit 506d8f1 for git v2.7.0, reverted in commit 76b620d git v2.8.0-rc0
- commit 5e57f9c git v2.8.0-rc0,... reverted(!) in commit 5cee3493 git 2.8.0-rc4.
However, since one of the rules to re-inclusion was:
The directory part in the re-include rules must be literal (i.e. no wildcards)
This wouldn't have worked here anyway.
这篇关于如何将不带点的文件(所有无扩展名的文件)添加到 gitignore 文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!