Last active
September 12, 2024 02:17
-
-
Save larsxschneider/85652462dcb442cc9344 to your computer and use it in GitHub Desktop.
Clone Git repositories and download LFS files in parallel
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
#!/usr/bin/env bash | |
# | |
# Clone Git repositories and download LFS files in parallel | |
# | |
set -e | |
CLEAN_ERROR='push @lines, $_;splice @lines, 0, 7 if /error: external filter failed/;print shift @lines if @lines > 6}{ print @lines;' | |
git -c filter.lfs.smudge= \ | |
-c filter.lfs.required=false \ | |
clone $@ 2>&1 | perl -ne "$CLEAN_ERROR" | |
if [[ -z $2 ]]; then | |
CLONE_PATH="$(basename ${1%.git})"; | |
else | |
CLONE_PATH="$2"; | |
fi | |
cd "$CLONE_PATH" | |
git-lfs pull | |
# Running `pull` a second time as a workaround for a Git-LFS bug | |
# c.f. https://github.com/github/git-lfs/issues/904#issuecomment-169092031 | |
git-lfs pull |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment