-
-
Save winterrdog/11a55439d9a1a14df036887c26f6b3d2 to your computer and use it in GitHub Desktop.
[BASH]clone_sub.sh
This file contains 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 | |
# First parameter is the sub-directory-absolute-path | |
# Second parameter is the link of the repo | |
# A smart split to get the repo-name, with / as a separator | |
REPO_NAME="$(echo $2 | grep -oE '[^/]+$')" | |
git init $REPO_NAME | |
cd $REPO_NAME | |
git remote add origin $2 | |
git config core.sparsecheckout true | |
# Specify the sub directory | |
echo "$1/*" >> .git/info/sparse-checkout | |
# then get it, the depth is the way too far where you can go... | |
git pull origin master | |
# and badaboum, you only get your sub-dir | |
# this script is functionnal for github/gitlab and bitbucket | |
# Have FUN (darker) ! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment