#!/usr/bin/env bash # # Handy single command to clone or pull a repository # # Parameters BASENAME="`basename $0`" ORIGIN="$1" DEST="$2" # Check if [ -z "$DEST" ]; then echo "usage: $BASENAME " exit 1 fi # Dispatch if [ ! -e "$DEST" ]; then echo "Cloning $ORIGIN into $DEST..." git clone $ORIGIN $DEST else echo "Updating $DEST..." git -C $DEST pull # Alternate approach, that restore any existing changes #( # cd $DEST &> /dev/null # git restore . # git pull #) fi # Exit exit $?