1

I have a private github repository with LFS enabled and some files already stored in LFS. As github's LFS bandwidth is rather limited (1GB of download a month on free plan), I have recently started switching to a self hosted gitea server, but for legacy automation reasons, I still need to push new commits to github.

Now I'm wondering, is there a way to only push the LFS link files to github and not the binary objects themselves, while retaining the ability to push LFS normally to my private gitea remote (the local cloned repository currently has 2 remotes set)? In my googling I've only found how to disable LFS for remotes that don't support it (github obviously does) or how to completely get rid of LFS in a repo, none of which sadly help my problem.

grizeldi
  • 180
  • 2
  • 12
  • It's certainly *possible*. The Git repository, when using the LFS wrappers, stores only the link file (for any files stored via LFS). So as long as you can get `git push` itself to operate as a pure Git-level `git push`, when pushing to GitHub, you will get exactly what you want. How Git-LFS overrides the default `git push` so as to run `git lfs push` instead, I don't know: that's what you'll need to defeat. – torek Mar 08 '22 at 21:16
  • @torek In this question, it looks like the way to defeat the pre push hook that uploads the LFS files is to use `git push --no-verify`, however the comments state that github rejects such pushes, which leaves me at square one. https://stackoverflow.com/questions/36626793/disable-git-lfs-for-a-remote – grizeldi Mar 09 '22 at 19:24
  • Ah. So, in this case, you not only need to defeat the pre-push hook in your own repository, but also the pre-receive hook in the *receiving* repository. Since that one is controlled by GitHub, it's possible if and only if you can control GitHub. Perhaps if you could have GitHub add a knob you can set via their web interface... but you will have to ask GitHub to do that. – torek Mar 10 '22 at 00:16

1 Answers1

1

got stuck on this; I had this the other way around. Github did have LFS and my custom remote repo did not.

I ran this command:

git config remote.<custom_remote_without_lfs>.lfsurl ""

replace <custom_remote_without_lfs> with the name of your remote listed in git remote -v. This sets the LFS URL for the custom remote to an empty string, effectively disabling LFS for that remote.

Max Visser
  • 577
  • 4
  • 10