answered 2023-04-04 13:17:48 +0000
You can combine "git checkout" with "find". This will work assuming the directories "dir1" and "dir2" cause the error...
find . -type f -path "*/path/here" | grep -v -E "(dir1|dir2)" | xargs -I '{}' git checkout -- '{}'