Last active
December 3, 2018 20:56
-
-
Save DSchau/fcf6d37c87bf5cba1e23824321bb1fc0 to your computer and use it in GitHub Desktop.
A shell script to clone a folder in a repo
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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