Skip to content

Instantly share code, notes, and snippets.

@DSchau
Last active December 3, 2018 20:56
Show Gist options
  • Select an option

  • Save DSchau/fcf6d37c87bf5cba1e23824321bb1fc0 to your computer and use it in GitHub Desktop.

Select an option

Save DSchau/fcf6d37c87bf5cba1e23824321bb1fc0 to your computer and use it in GitHub Desktop.
A shell script to clone a folder in a repo
#!/bin/bash
# shallow_clone local_folder example-name
## shallow_clone using-jest-example using-jest
fun shallow_clone () {
folder=$1
example=$2
mkdir $folder
cd $folder
git init
git remote add -f origin [email protected]:gatsbyjs/gatsby.git
# sparse checkout
## We would revert this after or reset to initial value if we're being "safe"
git config core.sparseCheckout true
echo "examples/$example" >> .git/info/sparse-checkout
git pull --depth=1 origin master
rm -rf .git
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment