Skip to content

Instantly share code, notes, and snippets.

@jhrcook
Last active May 5, 2019 12:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jhrcook/f154b644120698afdba5d06ed1b0709a to your computer and use it in GitHub Desktop.
Save jhrcook/f154b644120698afdba5d06ed1b0709a to your computer and use it in GitHub Desktop.
Installing git-lfs on O2

Git Large File Storage

A repository can use git large file storage ("git-lfs") to manage large data files.

Installation

The instructions on installing git-lfs for Mac, Windows, and some linux distros are available on the git-lfs GitHub repo Wiki. Since I did this work remotely on the HMS Research Computing Cluster, I do not have root access and had to install from source.

  1. Download the source code of the latest release from here.
wget https://github.com/git-lfs/git-lfs/releases/download/v2.7.2/git-lfs-v2.7.2.tar.gz
  1. Build the binary using go build -o /path/to/dest/git-lfs, where /path/to/dest/git-lfs is the name of the directory you store your installed software in. This directory should be in your $PATH. For instance, I used ~/bin/git-lfs.
module load go
go build -o ~/bin/git-lfs

There should now be a file with the same path and name that you passed using the -o flag.

  1. Set up git-lfs in your git repository.
cd /path/to/my/git/repo
git lfs install
#> Updated git hooks.
#> Git LFS initialized.
  1. Declare which files to track.
git lfs track "*.bigfiles"
#> Tracking "really_big_file.bigfiles"
#> Tracking "so_big_such_wow.bigfiles"
#> Tracking "large_files_rock.bigfiles"

where "*.bigfiles" is the regular expression for large files in the repo.

  1. Track ".gitattributes".
git add .gitattributes
git commit .gitattributes -m "start git-lfs"

You should now be able to add, commit, and push files like normal. Steps 1 and 2 only need to be done once per machine. Steps 3-5 need to be completed once per repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment