Skip to content

Instantly share code, notes, and snippets.

@micimize
Created May 19, 2019 21:22
Show Gist options
  • Save micimize/c314feb46182ddc875aa31f9166ed44d to your computer and use it in GitHub Desktop.
Save micimize/c314feb46182ddc875aa31f9166ed44d to your computer and use it in GitHub Desktop.
helper to clone a repo for inspection (relatively) cheaply
function cheap_clone {
EXTERNAL_CLONE_DIR="~/code/external"
# mkdir -p $EXTERNAL_CLONE_DIR
GIT_HOST='github.com'
BRANCH='master'
while [[ $# -gt 0 ]]
do
key="$1"
case $key in
-h|--host)
GIT_HOST=$2
shift # past argument
shift # past value
;;
-b|--branch)
BRANCH=$2
shift # past argument
shift # past value
;;
*)
REPO=$key
shift # past argument
;;
esac
done
if [ -z "$REPO" ]
then
echo $REPO
echo "ERROR: positional argument repo must be supplied"
return
fi
cd $EXTERNAL_CLONE_DIR
git clone --depth 1 \
--single-branch --branch $BRANCH \
git@${GIT_HOST}:${REPO}.git ${REPO}
cd $REPO
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment