Skip to main content

关于 Git 大文件存储系统

GitHub 限制存储库中允许的文件大小。 要跟踪超出此限制的文件,您可以使用 Git Large File Storage。

About Git Large File Storage

Git LFS handles large files by storing references to the file in the repository, but not the actual file itself. To work around Git's architecture, Git LFS creates a pointer file which acts as a reference to the actual file (which is stored somewhere else). GitHub manages this pointer file in your repository. When you clone the repository down, GitHub uses the pointer file as a map to go and find the large file for you.

Different maximum size limits for Git LFS apply depending on your GitHub plan.

ProductMaximum file size
GitHub Free2 GB
GitHub Pro2 GB
GitHub Team4 GB
GitHub Enterprise Cloud5 GB

If you exceed the per-file limit of 5 GB, the file will be rejected by Git LFS with an error message.

You can also use Git LFS with GitHub Desktop. For more information about cloning Git LFS repositories in GitHub Desktop, see Cloning a repository from GitHub to GitHub Desktop.

You can choose whether Git LFS objects are included in source code archives, such as ZIP files and tarballs, that GitHub creates for your repository. For more information, see Managing Git LFS objects in archives of your repository.

Pointer file format

Git LFS's pointer file looks like this:

version https://git-lfs.github.com/spec/v1
oid sha256:4cac19622fc3ada9c0fdeadb33f88f367b541f38b89102a3f1261ac81fd5bcb5
size 84977953

It tracks the version of Git LFS you're using, followed by a unique identifier for the file (oid). It also stores the size of the final file.

注意

  • Git LFS cannot be used with GitHub Pages sites.
  • Git LFS cannot be used with template repositories.

Further reading