Skip to content

Instantly share code, notes, and snippets.

Last active Jan 4, 2022
What would you like to do?
Quickly check all your git repos for local & remote changes.
set -o nounset
set -o errexit
[[ ! -z ${DEV} ]] || { echo "DEV is not defined"; exit 1; }
# for each dir in DEV
checkouts=$(find $DEV -maxdepth 1 -type d)
for dir in ${checkouts}; do
# skip dirs that aren't git clones
if [[ ! -d ${dir}/.git ]]; then continue; fi
local_changes=$(git -C ${dir} status --porcelain)
if [[ ! -z ${local_changes} ]]; then echo -e "${dir}: local changes\n${local_changes}"; fi
git -C $dir fetch -q
remote_changes=$(git -C ${dir} log HEAD..origin/master --oneline)
if [[ ! -z ${remote_changes} ]]; then echo -e "${dir}: remote updates\n${remote_changes}"; fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment