Instantly share code, notes, and snippets.

@air /checkgit.sh
Last active Jul 12, 2018

Embed
What would you like to do?
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