Skip to content

Conversation

@Srinivasan-tm
Copy link
Contributor

Git Sparse checkout script for selectively cloning folders from a repository

Srinivasan T M added 3 commits January 22, 2024 11:39
* Optionally include branch to pull from, defaults to "main"
* cd || exit is a popular pattern to make sure your program exits if cd
fails, but there is no change cd fails in this scenario as we are
performing mkdir in the previous step, so removing "|| exit"
if [ "$(git remote show | wc -l)" = "0" ]; then
git remote add origin "$REMOTE"
fi
git config core.sparseCheckout true
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't want to make permanent changes to my config. Can we enable flag only on commands that need it.

fi

# This specifies the remote URL from which to fetch from
REMOTE="$(echo "$URL" | sed -n 's|\(.*github.com\)/\([^/]*\)/\([^/]*\)/\(.*\)|\1/\2/\3.git|p')"
Copy link
Contributor

@rickygarg rickygarg Feb 21, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can it be generic so that it works on non github.com URLs also

If it's easier, we can just ask for these three params separately, instead of deriving from URL

Srinivasan T M and others added 2 commits February 21, 2024 18:43
missing files did not restore the missing files + fixed issue where
running this script did not pull remote changes to local
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants