Search code examples
gitversion-controlgithub

Is there any functionality in git to check multiple git repos under a directory?


I've got multiple git repos under a directory, and I was wondering whether there was some functionality in git to iterate each directory, check whether there are any uncommitted changes and report those to me?

I could run this every morning to ensure everything is up to date.

It's just that on any one day, I'll be working with multiple repos and I'll forget to commit my changes, which can cause conflicts when I realise much later on to commit them.

Chris


Solution

  • Andy is right (in the comments): if the parent directory is itself the root directory of a parent repo, with all the subdirectories as submdules, then 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 a scripting solution at "git: Find all uncommited locals repos in a directory tree".