Skip to content

Instantly share code, notes, and snippets.

@larsxschneider
Last active November 21, 2023 10:22
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save larsxschneider/85652462dcb442cc9344 to your computer and use it in GitHub Desktop.
Save larsxschneider/85652462dcb442cc9344 to your computer and use it in GitHub Desktop.
Clone Git repositories and download LFS files in parallel
#!/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