An Emacs dired buffer for ~/. is open.
I move the cursor to ~/proj and do the C-u i -alR dance (recursive dired-maybe-insert-subdir).
But the folder ~/proj has a subfolder ~/proj/.git and a file ~/proj/.gitignore.
How can I run recursive dired-maybe-insert-subdir while ignoring the files and folders that appear in ~/proj/.gitignore?
Not sure I understand the question.
But if you can't omit the particular files or subdirs you want to omit by using ls switches, you can perhaps omit them by using dired-omit-mode (C-x M-o) or dired-hide-subdir ($).
(For dired-omit-mode you need to load standard library dired-x.)