Skip to content

Instantly share code, notes, and snippets.

@air
Last active January 4, 2022 09:21
Show Gist options
  • Save air/0f0631106161b12f407f to your computer and use it in GitHub Desktop.
Save air/0f0631106161b12f407f to your computer and use it in GitHub Desktop.
Quickly check all your git repos for local & remote changes.
#!/bin/bash
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
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment