Skip to content

Instantly share code, notes, and snippets.

@noqqe
Created February 17, 2013 18:55
Show Gist options
  • Select an option

  • Save noqqe/4972784 to your computer and use it in GitHub Desktop.

Select an option

Save noqqe/4972784 to your computer and use it in GitHub Desktop.
Simple bash version of a gitolite slave.
#!/bin/bash
MASTER="git@example.com"
BASEDIR="/data/gitslave/"
for repo in $(ssh $MASTER | grep '^ R' | awk '{print $3}') ; do
if [ -d $BASEDIR/$repo ]; then
cd $BASEDIR/$repo
for rbranch in $(git branch -a | grep -v '^*\ master\|HEAD\ -' | awk -F/ '{print $3}'); do
git checkout $rbranch
git pull origin $rbranch
done
cd - &>/dev/null
else
git clone $MASTER:$repo $BASEDIR/$repo
fi
done &>/dev/null
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment