Git LFS
Keep your big files, such as game art, design files, models and datasets, in a CloudRepo Git LFS repository. Your code
stays where it is today, on GitHub, GitLab, Bitbucket or your own Git server. Only the large files move to CloudRepo, and
git push, git clone and git lfs pull work as they always do.
Before you start
Section titled “Before you start”- A Git LFS repository. If you have none, see Create Your First Repository and choose Git LFS.
- A repository token with Download and publish packages access to it, from Repository Tokens: Create One and Authenticate. The username is the email address of the account that created the token, and the password is the token.
- Git with Git LFS installed. Run this once on each machine:
git lfs installPoint Git LFS at CloudRepo
Section titled “Point Git LFS at CloudRepo”1. Give Git LFS your token. Git LFS reads it from ~/.netrc:
machine your-org.mycloudrepo.iologin you@example.compassword YOUR_REPOSITORY_TOKENKeep the file readable by you alone: chmod 600 ~/.netrc. Git LFS also uses the credential helper Git already uses,
so you can store the token there instead.
2. Point your repository at CloudRepo. In your repository, save the address in .lfsconfig. You commit this file, so
everyone who clones the repository uses CloudRepo too. The second line has Git LFS send your token from the first
request, so each large file is uploaded once:
git config -f .lfsconfig lfs.url https://your-org.mycloudrepo.io/repositories/your-repo/info/lfsgit config -f .lfsconfig lfs.https://your-org.mycloudrepo.io/repositories/your-repo/info/lfs.access basicPush your large files
Section titled “Push your large files”3. Choose the files Git LFS keeps. This tracks every Photoshop file:
git lfs track "*.psd"4. Commit and push as usual. Here art/hero.psd stands for your large file:
git add .gitattributes .lfsconfig art/hero.psdgit commit -m "Store Photoshop files in Git LFS on CloudRepo"git pushExpected: before Git pushes your commit, Git LFS uploads the file to CloudRepo and prints
Uploading LFS objects: 100% (1/1). Your Git host stores only a small pointer to it.
Get the files back
Section titled “Get the files back”A teammate who clones the repository gets the files from CloudRepo, as long as their ~/.netrc holds a token too.
In a clone made before the files were added, fetch them with:
git lfs pullLimits
Section titled “Limits”- One file is at most 50 GB.
- Git LFS asks for at most 300 files at a time. It asks for 100 unless you raise
lfs.transfer.batchSize. - CloudRepo stores each file once, by its SHA-256, and never replaces it. A file whose bytes do not match its pointer is refused, and nothing is stored.
- File locking (
git lfs lock) is not available yet. Pushes are never held waiting for a lock. - A Git LFS repository is always private. Every call needs your token.
Moving from GitHub, GitLab or Artifactory
Section titled “Moving from GitHub, GitLab or Artifactory”Run these in an up-to-date clone of your repository, while Git LFS there still uses your old server.
1. Fetch every file from your old server, for every branch and tag:
git lfs fetch --all2. Point this clone at CloudRepo. The first two lines are step 2 above. The third saves the address in this clone’s
own Git config too, because an lfs.url set there or in your global Git config wins over .lfsconfig, and Git LFS
would send your files back to the old server:
git config -f .lfsconfig lfs.url https://your-org.mycloudrepo.io/repositories/your-repo/info/lfsgit config -f .lfsconfig lfs.https://your-org.mycloudrepo.io/repositories/your-repo/info/lfs.access basicgit config lfs.url https://your-org.mycloudrepo.io/repositories/your-repo/info/lfsgit lfs envExpected: git lfs env prints Endpoint=https://your-org.mycloudrepo.io/repositories/your-repo/info/lfs (auth=basic).
3. Upload every file, then share the address. git lfs push --all on its own uploads only what your local
branches use, so the first line hands it every branch and tag, your Git host’s too. Committing .lfsconfig moves your
team to CloudRepo:
git for-each-ref --format='%(refname)' | git lfs push --all --stdin origingit add .lfsconfiggit commit -m "Keep large files on CloudRepo"git push4. Check that CloudRepo has every file. This downloads them all again, from CloudRepo alone, into a spare folder,
.git/lfs-check, and stops with an error naming any file CloudRepo does not have. Delete the folder afterwards:
git -c lfs.storage=lfs-check lfs fetch --allBefore you shut the old server down, run git lfs env in each clone your team uses and check that it shows your
CloudRepo address; a clone that still shows the old one needs the third line of step 2. Nothing else in your repository
changes.