Skip to content

Instantly share code, notes, and snippets.

@schwuk
Last active August 28, 2018 09:22
Show Gist options
  • Save schwuk/983f4cc5bd9d87ee0f3d58d09d04b987 to your computer and use it in GitHub Desktop.
Save schwuk/983f4cc5bd9d87ee0f3d58d09d04b987 to your computer and use it in GitHub Desktop.
Simple shell script to update all git repositories in a directory. Requires the `lockfile` utility from Procmail.
#!/bin/sh
# Updates git repositories
LOCKFILE=/tmp/git.lock
lockfile -r 0 $LOCKFILE || exit 1
GIT=`which git`
for i in `ls`; do
echo $i
cd $i
if [[ -e .git ]]; then
git fetch --all --prune
git pull
fi
cd -
done
rm -f $LOCKFILE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment