How to recursively verify which git files were modified

When you have a project consisting of several git repositories it is difficult to walk manually one by one to discover what have changed.

Today I was trying to know which files I modified on Android project (many git repositories) and I got it done using this command line:

$ find . -name .git -print0 | sed s/\.git//g | xargs -0 -r -I file git --git-dir=file.git --work-tree=file status

Let me to explain it: first I search for all “.git” directory (the repository) and use -print0 to separate each file (in fact it is a git directory) with \null. Then I used “sed” to remove the “.git” directory name from original path name (this is a trick because “–git-dir” needs the complete path name but “–work-tree” needs not, see more ahead) and I passed this base directory (where the “.git” is locate) to xargs. Finally I used the “-I” to save this received path on “file” variable (because I need to use it twice) and added “.git” on it when using “–git-dir” parameter and just “file” for “–work-tree”.

I got all information I needed to create it here:

I hope it will be useful to you.