Configuring Git LFS To Use Dropbox

Created: 9 Aug 2019

Updated: 9 Aug 2019

Backstory

I need to store binary and large files in git, more specifically in GitHub, which supports LFS. However, I only get 1 GB of LFS space for free, after that I have to pay $60/year for 50 GB (price as of 9 Aug 2019). Well, I already own a Dropbox subscription. I want to point my LFS to a local Dropbox folder and save myself money. I did some research and found a git custom transfer adapter that allows me to do just what I want.

Prerequisites

For this tutorial I assumed the following tasks are already done.

  1. You have git installed, v2.19.1 or later
  2. You have LFS installed, v2.3.0 or later

Tutorial Time

Step 1, download and setup LFS FolderStore which “allows you to use a plain folder as the remote storage location for all your large media files.” Follow the download & install instructions.

The next few steps are the order I use to create my project and add it to version control, but it isn’t the only way. 😊

Step 2, create your Unity project.

Step 3, create a ‘_Game’ and ‘Sprites’ folder under the ‘Assets’ folder. See my Folder Structure entry on my Tips & Tricks page for why I create a ‘_Game’ folder first.

Step 4, add some picture files to the Sprites folder. These files enable you to test your setup.

Step 5, add a ‘.gitattributes‘ file to the root project folder. This configures which file types are handled by LFS.

Step 6, add a ‘.gitignore‘ to the root project folder.

Step 7, open git bash in the root project folder.

Step 8, enter git init to initialize the local git repo.

Step 9, enter git add -A to stage all the files.

Step 10, enter git commit -m "initial commit" to commit everything locally.

Step 11, create a repo on GitHub, no license, no readme, no git ignore. I assume this can be done with GitLab and Bitbucket but I haven’t tested them. If you have please let me know.

Step 12, setup the remote origin, in the git bash window enter git remote add origin https://github.com/{GitHubName}/{ProjectName}.git. Replace the items in the {} with your info.

Now I start the configure a fresh repo section of the LFS FolderStore instructions.

❗ Make sure you have the ‘lfs-folderstore.exe’ added to the path. ❗

Step 13, enter git config --add lfs.customtransfer.lfs-folder.path lfs-folderstore to add the custom transfer agent.

Step 14, enter git config --add lfs.customtransfer.lfs-folder.args "C:/{path/to}/Dropbox/{path/to/LFS}/{ProjectName}" to point the agent to your local folder. I created a LFS folder in my Dropbox and then created a folder for each project. Replace the items in the {} with your info.

Step 15, enter git config --add lfs.standalonetransferagent lfs-folder as the last config item.

Step 16, enter git push origin master to push the code to your remote and LFS folder.

Now you can check your local LFS folder and you will find your files there, and if you check GitHub your Git LFS Data (in the Billings section of Settings) shouldn’t have increased.

Epilogue

Note, that you have to set this up again on every machine you use to develop your game. You can’t store a custom transfer agent config in GitHub due to security concerns. I mean I wouldn’t trust a repo that downloaded a “random EXE” and configured my system to use it, would you? In fact, this is my next step, I need to configure this on my wife’s machine and make sure everything works correctly.

%d bloggers like this: