Thanks to visit codestin.com
Credit goes to gist.github.com

Skip to content

Instantly share code, notes, and snippets.

@source-c
Last active September 8, 2025 15:08
Show Gist options
  • Save source-c/1b08cf30de8bde06ae3e8dda331e95ac to your computer and use it in GitHub Desktop.
Save source-c/1b08cf30de8bde06ae3e8dda331e95ac to your computer and use it in GitHub Desktop.
update-all-project-repositories
#!/usr/bin/env bash
ALL_REPOS=$(ls -1)
GIT_EXE="git"
GIT_PULL_CMDLINE="pull --all --ff"
GIT_FALLBACK="pull --all --rebase"
GIT_PRUNE_ORIGIN="remote prune origin"
echo $(pwd)
for i in ${ALL_REPOS}; do
echo ">>> ${i} <<<"
if [ -d ${i}/.git -a ! -f ${i}/.no-auto-update ]; then
cd ${i}
${GIT_EXE} ${GIT_PULL_CMDLINE}
if [ $? != 0 ]; then
${GIT_EXE} ${GIT_FALLBACK}
[ $? != 0 ] && ${GIT_EXE} ${GIT_PRUNE_ORIGIN} && ${GIT_EXE} ${GIT_FALLBACK}
fi
[ $? == 0 ] && echo "~~ DONE: ${i}" || exit 2 ## left the execution at the problematic loc
echo
cd -
else
echo "** DONE: ${i} -- not a GIT repo target. Skipping..."
fi
done
echo "ALL DONE"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment