Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git path to match any directory name

Tags:

git

glob

In git we can use * to specify files name, like *.jpg, *.*, but how about directories?

Is there any method to specify all directory?

This doesn't work:

git rm firstdirectory/*/thirddirectory

The * doesn't do the "all directories" effect.

like image 855
Rico Chan Avatar asked Oct 22 '22 15:10

Rico Chan


1 Answers

Your command doesn't work because you're specifying a directory to git. Your shell does the correct expansion, but in the end git receives git rm firstdirectory/somedir/thirddirectory, which git doesn't like (git rm expects files)

To make your command work, use the -r flag, then git accepts directory:

git rm -r firstdirectory/*/thirddirectory
like image 114
CharlesB Avatar answered Oct 31 '22 14:10

CharlesB