Skip to content

Instantly share code, notes, and snippets.

@source-c
Last active February 11, 2023 08:13
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_MAIN_EXECUTABLE="git"
GIT_PULL_CMDLINE="pull --all --ff"
GIT_FOLLBACK="pull --all --rebase"
echo $(pwd)
for i in ${ALL_REPOS}; do
echo ">>> ${i} <<<"
if [ -d ${i}/.git -a ! -f ${i}/.no-auto-update ]; then
cd ${i}
${GIT_MAIN_EXECUTABLE} ${GIT_PULL_CMDLINE} || ${GIT_MAIN_EXECUTABLE} ${GIT_FOLLBACK}
[ $? == 0 ] && echo "~~ DONE: ${i}" || exit 2
echo
cd -
else
echo "~~ DONE: ${i} -- not a GIT repo"
fi
done
echo "ALL DONE"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment