Are there any functions in git for checking multiple git repositories in a directory?

I have several git repos in a directory, and I was wondering if there is any functionality in git to iterate through each directory, check for any uncommitted changes and report it to me?

I could run this every morning to keep things up to date.

It’s just that on any day I’ll work with several repositories, and I will forget to make my changes, which can cause conflicts when I realize that I’ll make them later.

Chris

+1
git version-control github
source share
4 answers

Andy is correct (in the comments): if the parent directory itself is the root directory of the parent repo, with all the subdirectories as subtasks, then the git status can detect any changes in one of them.

You can also use (with submodules) git diff

 git submodule foreach --recursive git diff --name-status 

Without submodules, see the script solution in the git section : find all the irregular locale repositories in the directory tree .

+1
source share
0
source share

Add this alias to your .gitconfig file, and then you can run git status-all from the parent directory to recursively get the status of all git repositories.

 [alias] status-all = "!for d in `find . -name \".git\"`; do echo \"\n*** Repository: $d ***\" && git --git-dir=$d --work-tree=$d/.. status; done" 
0
source share

I don't think git has this assembly, so some time ago I created a script for this: https://github.com/mnagel/clustergit

clustergit allows clustergit to run git commands on multiple repositories at once. It is especially useful to run git recursion in one folder. clustergit supports git status , git pull , git push , etc.

enter image description here

0
source share

All Articles