Skip to content

Instantly share code, notes, and snippets.

@scarytom
Created September 23, 2019 08:34
Show Gist options
  • Save scarytom/78d9a16696034d70e1e3980bf5ae193d to your computer and use it in GitHub Desktop.
Save scarytom/78d9a16696034d70e1e3980bf5ae193d to your computer and use it in GitHub Desktop.
Pull all git repos
#!/bin/sh -eu
echo "pulling all projects..."
for d in "${HOME}"/projects/*; do
if [ -d "${d}/.git" ]; then
CURRENT_BRANCH="$(git -C "${d}" rev-parse --abbrev-ref HEAD)"
[ "${CURRENT_BRANCH}" = 'master' ] || echo -e "\r\033[KWARNING: ${d} is not on branch master"
if [ -z "$(git -C "${d}" status --porcelain)" ]; then
echo -en "\r\033[K ${d}"
git -C "${d}" pull --rebase --quiet
else
echo -e "\r\033[KERROR: ${d} is dirty"
fi
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment