-
-
Save Hardu2203/60306dbad152675d29401d318c65aa38 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 | |
# Specipy the sub directory | |
echo "$1/*" >> .git/info/sparse-checkout | |
# then get it, the depth is the way too far wher 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) ! |
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 | |
git clone --filter=blob:none --no-checkout --depth 1 --sparse $2 | |
# A smart split to get the repo-name, with / as a separator | |
REPO_NAME="$(echo $2 | grep -oE '[^/]+$')" | |
cd $REPO_NAME | |
git sparse-checkout init --cone | |
git sparse-checkout add $1 | |
git checkout |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment