Created
October 19, 2023 20:07
-
-
Save scottstanie/4166da254a7366cf2a61bf2dacc5d8f9 to your computer and use it in GitHub Desktop.
Setup `git lfs` on either linux or Mac M1/M2 using the github release binaries
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
#/usr/bin/env bash | |
set -e | |
set -x | |
# Check if INSTALL_PREFIX is set; otherwise, error | |
if [ -z "$INSTALL_PREFIX" ]; then | |
echo "INSTALL_PREFIX is not set" | |
echo "Example usage: INSTALL_PREFIX='~/.local/bin' bash $0" | |
exit 1 | |
fi | |
prefix="$INSTALL_PREFIX" | |
# https://github.com/git-lfs/git-lfs/releases | |
linux_url="https://github.com/git-lfs/git-lfs/releases/download/v3.4.0/git-lfs-linux-amd64-v3.4.0.tar.gz" | |
linux_sha256="60b7e9b9b4bca04405af58a2cd5dff3e68a5607c5bc39ee88a5256dd7a07f58c" | |
osx_arm_url="https://github.com/git-lfs/git-lfs/releases/download/v3.4.0/git-lfs-darwin-arm64-v3.4.0.zip" | |
osx_arm_sha256="114fadc3dee4ee6e29b57823b337549c823b8b0680f33190f29a5700e4b29196" | |
# Check what machine the user is on | |
# If on linux, download the linux version of git-lfs | |
# If on mac, download the mac version of git-lfs | |
if [[ "$OSTYPE" == "linux-gnu"* ]]; then | |
url="$linux_url" | |
sha="$linux_sha256" | |
elif [[ "$OSTYPE" == "darwin"* ]]; then | |
url="$osx_arm_url" | |
sha="$osx_arm_sha256" | |
else | |
echo "Unsupported OS" | |
exit 1 | |
fi | |
# Download the git-lfs binary | |
wget "$url" | |
filename=$(basename "$url") | |
# Verify the checksum | |
# If it fails, error | |
if [[ "$OSTYPE" == "linux-gnu"* ]]; then | |
echo "$sha $filename" | sha256sum -c - | |
elif [[ "$OSTYPE" == "darwin"* ]]; then | |
shasum -a 256 -c <<<"$sha *$filename" | |
fi | |
# Extract, setting the prefix to a local directory for the install | |
tar -xvf $filename | |
rm $filename | |
export PREFIX="$prefix" | |
bash git-lfs-*/install.sh |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment