#!/bin/bash declare -A usage declare -A varia summary="$0 [options] " usage[b]="Branch of git repo" varia[b]=branch branch=master usage[d]="Destination of clone" varia[d]=dst dst='.' usage[i]="privkey used to ssh pull" varia[i]=privkey privkey='' . driglibash-args # Some SSH options ssh_opt='ssh' if [ -n "$privkey" ] ; then ssh_opt="$ssh_opt -i $privkey" fi repo="$1" if [ -z "$repo" ] ; then die "$0: Empty repo given\n$summary" fi cd "$dst" if [ -d .git ] ; then git reset --hard HEAD && git pull --depth 1 --ff-only --rebase --config core.sshCommand="$ssh_opt" git submodule update --recursive --remote --recommend-shallow else git clone --single-branch --recurse-submodules --shallow-submodules --depth 1 --config core.sshCommand="$ssh_opt" "$repo" . fi