find source code in certain directories

Question: How to exclude *.tsx, migrations files, and python tests files?

In git grep

git grep 'tiger' -- '*.py' ':!*tests*' ':!*migrations*'
# same as 
git grep 'tiger' -- '*.py' ':(exclude)*tests*' ':(exclude)*migrations*'

After the -- the patterns used are <pathspec>, see man gitglossary.

In Rg

rg 'tiger' --glob '!{**/tests/*,**/migrations/*}'

# if you are sure there are no files with name `tests` or `migations`, you
# can do
rg 'tiger' --glob '!{tests,migrations}'

rg 'tiger' -g '!tests' -g '!migrations'