Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git ignore random numeric folders name

Tags:

git

I want to ignore some folders generated with random numeric names even float numbers, but I do not know how to peek them to include in the .gitignore file

like image 1000
efirvida Avatar asked May 14 '26 06:05

efirvida


2 Answers

How about something like:

* //Ignore everything

!*[!0-9.]* //Except things with some characters besides numbers (and period, for decimals) in them
!*.*.* //And except things with two periods, since these can't be numbers

Note that these are shell globs instead of regular expressions.

like image 198
Chris Avatar answered May 15 '26 19:05

Chris


Ideally, if gitignore supported regular expression, it might have been possible to use a regex as detailed here.

However, from the official git documentation here :

Otherwise, Git treats the pattern as a shell glob suitable for consumption by fnmatch(3) with the FNM_PATHNAME flag: wildcards in the pattern will not match a / in the pathname. For example, "Documentation/*.html" matches "Documentation/git.html" but not "Documentation/ppc/ppc.html" or "tools/perf/Documentation/perf.html".

Regular expression is not supported at the time of this writing (2016-11-15) and the expressions in gitignore are interepreted as shell glob patterns.

If the random folders being generated do not share a common parent directory and there is nothing else common in their names, then this does seem to be possible.

Is it possible to generate the folders with a common prefix or suffix so that that can be used in the .gitignore?

like image 34
Ashutosh Jindal Avatar answered May 15 '26 19:05

Ashutosh Jindal