Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I write a more compact rule for git add?

Tags:

git

I need add into the staged area all ini files of current directory and its subdirectories recursively. Is exist a single filter for it?

I use it:

git add *.ini ./**/\*.ini

So I pointed two selection rules. Can I write it more compactly through a single rule?

I tried such variants: **/\*.ini, ./**/\*.ini, */**/\*.ini but these are not the same.

like image 620
Andrey Bushman Avatar asked Jul 09 '15 12:07

Andrey Bushman


2 Answers

Use git add "*.ini". By putting *.ini in quotes you avoid that your shell is expanding the pattern to only the matching file(s) in your current directory before even passing the argument to git.

like image 96
sschuberth Avatar answered Nov 17 '22 17:11

sschuberth


In general, you can use find for more complicated operations:

find . -type f -name '*.ini' -exec git add {} +
like image 31
Will Vousden Avatar answered Nov 17 '22 15:11

Will Vousden