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:
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:
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.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…