19

I am making use of git lfs for storage of large files in a github repository. The only problem is that there is a quota for git lfs; specifically you can only store 1 GB and only stream (download) 1 GB per month. After you run out of that, you must pay $5 for 5 more GB. This could become expensive.

I have an old PC I could boot Linux and port forward on.

Does anyone know how to setup a git lfs server at home rather than using Github's lfs built in CPU's?

GeneralCode
  • 794
  • 1
  • 11
  • 26

2 Answers2

12

There are a variety of implementations that you can use, and there's a reference server implementation you can use for testing or production use.

bk2204
  • 64,793
  • 6
  • 84
  • 100
  • 2
    But this does not explain how do you configure git to use your server for lfs and continue to use GitHub for the rest. – SCLeo Aug 09 '22 at 01:18
  • Is there any information about git lfs reference client implementation too somewhere? I'm looking for alternative client applications that don't use Go. – JCMiguel Oct 11 '22 at 13:58
  • I'm not aware of alternate client implementations that aren't bridges. If they existed, they would be listed on the same wiki page. – bk2204 Oct 11 '22 at 16:01
4

Starting with git-lfs version 2.10.0 (released 2020-01-21) it's now possible to git lfs push and fetch against bare repos on the local file system (i.e. with the remote URL set to file://... or even with /path/to/bare-repo.git).

For example:

git clone /path/to/local-git-repo.git
cd local-git-repo
echo 'hello world' > hello.txt
git lfs track '/hello.txt'
git add .

This will create a local .git/lfs/objects directory.

git commit -m 'Add, track LFS file'
git push

This will push lfs objects to /path/to/local-git-repo.git/lfs/objects.

You'll probably need to setup git lfs in your global config if it isn't there already.
git config --global filter.lfs.clean 'git-lfs clean -- %f'
git config --global filter.lfs.process 'git-lfs filter-process'
git config --global filter.lfs.required 'true'
git config --global filter.lfs.smudge 'git-lfs smudge -- %f'
amphetamachine
  • 27,620
  • 12
  • 60
  • 72
  • is it possible to push to github as a remote while pushing only LFS objects to a local server (via file:// protocol)? – Chad Aug 17 '23 at 14:13
  • @Chad I'm not sure why you would want to do that; anyone who clones the repo from Github will not be able to clone the repo as they won't receive the LFS files. – amphetamachine Aug 17 '23 at 16:43
  • @Chad I suppose if you really wanted to keep huge files out of your code repo, you could try using a separate repo for your big files, then symlink them into your main repo. Git tracks symlinks just fine. – amphetamachine Aug 17 '23 at 16:43