如何将没有点(其所有扩展名文件)的文件添加到gitignore文件? [英] How do I add files without dots in them (all extension-less files) to the gitignore file?
问题描述
像标题所说,是否可以将没有点的文件添加到gitignore文件中?
我想这可以解决所有这些麻烦您可以尝试类似以下的组合:
<$>
$ b
*
!/ ** /
!*。*
gitignore
排除规则(a 否定模式)应忽略除扩展名外的所有文件。
如果排除该文件的父目录,则无法重新包含文件。( *
)
(<$ c
这就是为什么:除非在git 2.?+中满足某些条件, > / ** /
是很重要的(如果我们想要白名单文件,则递归地列出父文件夹)。
我提到过类似案例中的相同规则,例如:
由于JakubNarębski comments ,你可能不想忽略所有的扩展名文件。
我的建议:
- 首先添加无扩展文件
- 然后编辑您的
.gitignore
,如上所示:已经版本化的文件不会被忽略(即使它们没有扩展名)。所有其他文件都将被忽略。
对于任何您希望版本扩展的文件:
git add -f - myFile
< hr>
请注意,使用git 2.9.x / 2.10(2016年中期?),如果该文件的父目录被排除,那么可能会重新包含一个文件如果路径中没有通配符,则重新包含。
NguyễnTháiNgọcDuy( pclouds
) 正试图添加此功能:
- 提交506d8f1 为git v2.7.0,恢复在提交7 6b620d git v2.8.0-rc0
- 提交5e57f9c git v2.8.0-rc0,...在 commit 5cee3493 git 2.8.0-rc4。
然而,因为重新包含的规则之一是:
重新包含规则中的目录部分必须是literal(即没有通配符)
无论如何这不会有效。
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屋!