Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to ignore this file pattern?

Tags:

git

I want to ignore all files matching this pattern.

home - copy [1].php
home - copy [2].php
home - copy [3].php
filename - copy [1].php
anotherfile - copy [1].php
other - copy [1].php

There can be numbers inside [ and ]. What rule should be added in .gitignore for such files?

like image 644
Asif Ali Avatar asked Mar 15 '26 00:03

Asif Ali


1 Answers

EDIT: Apparently you can specify a number:

* - copy\ \[[0-9]*\].php

Unfortunately you can't use regex to specify a number in the [ ] but

* - copy\ \[*\].php

should work (although it would also filter test - copy [ab].php etc)

like image 61
Holloway Avatar answered Mar 16 '26 14:03

Holloway