Last active
January 4, 2022 09:21
-
-
Save air/0f0631106161b12f407f to your computer and use it in GitHub Desktop.
Quickly check all your git repos for local & remote changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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