Last active
September 8, 2025 15:08
-
-
Save source-c/1b08cf30de8bde06ae3e8dda331e95ac to your computer and use it in GitHub Desktop.
update-all-project-repositories
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
| #!/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