ulrik@kaizer.se/ hacks/
managing many git repos

To manage a swarm of git repositories, I put links to all important ones in ~/.local/git-repos and use these scripts.

#!/bin/sh

echo "This will attempt to push all git repos to a specified backup directory"

SYMLINKDIR="$HOME/.local/git-repos"
test -e $SYMLINKDIR
REPOS="$SYMLINKDIR/*"

[ "$1" ] && BUPDIR=$1 || BUPDIR=/media/default/bup

echo "Pushing all repos to $BUPDIR"
mkdir -p "$BUPDIR"

for repo in $REPOS; do
        cd "$repo"
        NAME="$(basename $repo).git"
        DSTDIR="$BUPDIR/$NAME"
        if test -e "$DSTDIR"
        then
                git push -v -f --all "$DSTDIR"
        else
                echo "$NAME does not exist at destiantion, creating..."
                git clone --bare . "$DSTDIR"
        fi
done
#!/bin/sh
COMMAND=$*
echo "This will attempt to run a git command for all repos"
echo git $COMMAND

#sleep to give some undo time
sleep 2

SYMLINKDIR="$HOME/.local/git-repos"

test -e $SYMLINKDIR

REPOS="$SYMLINKDIR/*"

set -x
for repo in $REPOS; do
    cd $repo && git $COMMAND
done