It's All Writing.

Writing makes you happy.

How to access lfs binary files from GitHub Pages

Environment

  • GitHub.com
  • GitHub Pages
  • lfs

Premise

At the GitHub.com, you can not push large file ( over 50MB ) to remote repository.
In this case, you can use lfs to solve this problem as below.

( in your local repository )
$ git lfs install
$ git lfs track "*.mp3"
$ git add audio/*.mp3
$ git add .
$ git commit -m "add mp3 files to lfs" -v
$ git push -u origin master

Then, you'll try to access lfs binary files ( at the example above, as audio/*.mp3 files ), but you can not access them.
GitHub.com does not allow you to access lfs binary files directry (e.g. https://username.github.io/audio/some.mp3 ) from GitHub Pages.

Solution

Instead of direct access, you can use special url as below.

https://media.githubusercontent.com/media/_Username_/_Project_/_Branch_/_Path_to_file_

e.g. https://media.githubusercontent.com/media/shinchit/shinchit.github.io/master/audio/some.mp3

Reference

github.com