Home > OS >  How to exclude gitignore folder named in a UUID pattern in Node.js
How to exclude gitignore folder named in a UUID pattern in Node.js

Time:11-10

I'm trying to git ignore a folder name with a UUID regex pattern - 6cbe8cac-c0b4-4e0b-b335-4db9a89c3119.

How do i achieve that?

I added

root-folder/[0-8]*-[0-4]*-[0-4]*-[0-4]*-[0-12]

to my .gitignore file but that didn't work.

CodePudding user response:

Your regex/glob pattern doesn't contain letters, the UUID you gave as example does.

you can try : [0-9a-zA-Z]*-[0-9a-zA-Z]*-[0-9a-zA-Z]*-[0-9a-zA-Z]*-[0-9a-zA-Z]*

It will match any file or folder name containing any 5 alphanumeric groups being hyphen separated (guessing all the UUIDs will have that form)

The numbers you put between square brackets [] are the range in which the characters should be, not the number of occurances ([0-9] means "exactly one digit between 0 and 9 and [0-9a-zA-Z] means exactly one character between a-z, A-Z OR 0-9) see : https://en.wikipedia.org/wiki/Glob_(programming)

But maybe your git project need subfolders in the first place (in which your UUID folders are generated). You could avoid doing such expressions in your .gitignore

  • Related