Created
September 23, 2019 08:34
-
-
Save scarytom/78d9a16696034d70e1e3980bf5ae193d to your computer and use it in GitHub Desktop.
Pull all git repos
This file contains hidden or 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/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