If git supports adding multiple files to a single command, the easiest way is to use the + suffix for -exec :
find . -name '*.js' -exec git add {} \+
This collects a large number of files and transfers them to the entire team on one command line.
So what will be done:
git add a.js b.js c.js d.js
instead
git add a.js git add b.js git add c.js git add d.js
If you process hundreds or thousands of files, this will significantly affect the execution time.
To combine all file templates into a single find , use the find or operator command:
find . \( -name '*.js' -o \ -name '*.html' -o \ -name '*.css' -o \ -name '*.py' -o \ -name '*.txt' -o \ -name '*.jpg' -o \ -name '*.sh' \) -exec git add {} +
\ ( and ) needed to protect them from their special shell value. Instead, you can use quotation marks: '(' , ')' .
find has several complex options, and you need to work a little to study them and get to know them, but over the years I have saved a lot of effort by dropping the difficult find and not struggle with filtering file names via grep and awk, etc.
One of my favorite patterns for scanning through the maven / subversion java project while ignoring uninteresting files:
find . \( \( \( -iname .svn -o -iname target -o -iname classes \) -type d -prune -false \) -o \( <your filter expression> \) \) -exec grep -li xxx {} +
source share