a06e
a06e

Reputation: 20774

Check which repos are in sync with the remote from a list of repos?

I have a directory that contains a bunch of git repos. All these repos have remotes in Github and Gitlab. What command can I execute to check, for each of these repos:

1- Which ones have uncommited changes. 2- Which ones have commits that have not been synced to the remote.

Upvotes: 0

Views: 175

Answers (1)

jingx
jingx

Reputation: 4014

I keep this script around which lets me apply a git command to every subdirectory:

#!/usr/bin/env zsh

submodules=("${(@f)$(find . -type d -depth 1)}")
for submodule in $submodules
do
    print "=== $submodule"
    git --work-tree=$submodule --git-dir=$submodule/.git $*
    print
done

[Edit] just to clarify: the submodule variable name in the script really should have been subdirectory. The script has nothing to do with git's submodule feature.

Upvotes: 1

Related Questions