Created
August 21, 2023 21:58
-
-
Save ebobby/061a53627a2d57e2beb7e8b4dc89c5a4 to your computer and use it in GitHub Desktop.
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 | |
| if [ -z "$1" ]; then | |
| echo "Need a directory of repositories to work with..." | |
| exit | |
| fi | |
| if [ -d $1 ]; then | |
| case "$1" in | |
| */) | |
| ROOT="$1"; | |
| ;; | |
| *) | |
| ROOT="$1/" | |
| ;; | |
| esac; | |
| echo "Root directory: $ROOT"; | |
| DIRS=`ls -d $1/*` | |
| for DIR in $DIRS; do | |
| GITREPO="$DIR/.git" | |
| if [ -d $GITREPO ]; then | |
| pushd $DIR | |
| echo "Updating $DIR..." | |
| BRANCH=`git branch | awk '{ print $1 }'` | |
| git stash | |
| # git checkout master &> /dev/null | |
| git fetch --all --prune | |
| git pull | |
| # git checkout $BRANCH &> /dev/null | |
| git prune | |
| git gc | |
| git stash pop | |
| popd | |
| fi | |
| done | |
| fi | |
| #!/usr/bin/env bash | |
| if [ -z "$1" ]; then | |
| echo "Need a directory of repositories to work with..." | |
| exit | |
| fi | |
| if [ -d $1 ]; then | |
| case "$1" in | |
| */) | |
| ROOT="$1"; | |
| ;; | |
| *) | |
| ROOT="$1/" | |
| ;; | |
| esac; | |
| echo "Root directory: $ROOT"; | |
| DIRS=`ls -d $1/*` | |
| for DIR in $DIRS; do | |
| GITREPO="$DIR/.git" | |
| if [ -d $GITREPO ]; then | |
| pushd $DIR | |
| echo "Updating $DIR..." | |
| BRANCH=`git branch | awk '{ print $1 }'` | |
| git stash | |
| # git checkout master &> /dev/null | |
| git fetch --all --prune | |
| git pull | |
| # git checkout $BRANCH &> /dev/null | |
| git prune | |
| git gc | |
| git stash pop | |
| popd | |
| fi | |
| done | |
| fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment