Skip to content

Instantly share code, notes, and snippets.

@ebobby
Created August 21, 2023 21:58
Show Gist options
  • Select an option

  • Save ebobby/061a53627a2d57e2beb7e8b4dc89c5a4 to your computer and use it in GitHub Desktop.

Select an option

Save ebobby/061a53627a2d57e2beb7e8b4dc89c5a4 to your computer and use it in GitHub Desktop.
#!/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