Skip to main content

此版本的 GitHub Enterprise 已停止服务 2022-10-12. 即使针对重大安全问题,也不会发布补丁。 为了获得更好的性能、更高的安全性和新功能,请升级到最新版本的 GitHub Enterprise。 如需升级帮助,请联系 GitHub Enterprise 支持

Configuring Git Large File Storage for your enterprise

Git Large File Storage (Git LFS) 是 Git 的开源扩展,使您能够像处理其他文本文件一� �处理大文件。

About Git Large File Storage

Git Large File Storage (Git LFS) 是 Git 的开源扩展,使您能够像处理其他文本文件一� �处理大文件。 You can use Git Large File Storage with a single repository, all of your personal or organization repositories, or with every repository in your enterprise. Before you can enable Git LFS for specific repositories or organizations, you need to enable Git LFS for your enterprise.

By default, the Git Large File Storage client stores large assets on the same server that hosts the Git repository. When Git LFS is enabled on your GitHub Enterprise Server instance, large assets are stored on the data partition in /data/user/storage.

如果在企业或仓库上禁用了 Git LFS,则用户� 法将 Git LFS 资产推送到 GitHub Enterprise Server 。

For more information, see "About Git Large File Storage", "Versioning large files," and the Git Large File Storage project site.

Configuring Git Large File Storage for your enterprise

  1. 在 GitHub Enterprise Server 的右上角,单击� 的个人资料照片,然后单击“企业设置”。 GitHub Enterprise Server 上个人资料照片下拉菜单中的“企业设置”

  2. 在企业边� �中,单击 “策略”。 企业帐户边� �中的“策略”选项卡

  3. “策略” 下,单击“选项” 。 企业帐户设置侧边� �中的“选项”选项卡

  4. Under "Git LFS access", use the drop-down menu, and click Enabled or Disabled. Git LFS Access

Configuring Git Large File Storage for an individual repository

注意:每个存储库自动从拥有它的组织或用户继承默认设置。 如果仓库所有者已在其所有仓库上强制执行设置,则您不能覆盖默认设置。

  1. 从 GitHub Enterprise Server 上的管理帐户任意页面的右上角,单击

    用于访问站点管理员设置的火箭图� �的屏幕截图

  2. 如果� 尚未在“站点管理员”页上,请在左上角单击“站点管理员”。

    “站点管理员”链接的屏幕截图

  3. 在搜索字段中,键入存储库的名称,然后单击“搜索”。 站点管理员设置搜索字段

  4. 在搜索结果中,单击仓库名称。 站点管理设置搜索选项

  5. 在页面的右上角,单击 “管理员”。管理员工具

  6. 在左侧� �中,单击“管理员”。管理员工具

  7. 在“Git LFS”下,单击“启用”或“禁用” 。 禁用按钮

Configuring Git Large File Storage for every repository owned by a user account or organization

  1. 从 GitHub Enterprise Server 上的管理帐户任意页面的右上角,单击

    用于访问站点管理员设置的火箭图� �的屏幕截图

  2. 如果� 尚未在“站点管理员”页上,请在左上角单击“站点管理员”。

    “站点管理员”链接的屏幕截图

  3. 在搜索字段中,键入用户或组织的名称,然后单击“搜索”。 站点管理设置搜索字段

  4. 在搜索结果中,单击用户或组织的名称。 站点管理设置搜索选项

  5. 在页面的右上角,单击 “管理员”。管理员工具

  6. 在左侧� �中,单击“管理员”。管理员工具

  7. 在“Git LFS”下,单击“启用”或“禁用” 。 禁用按钮

Configuring Git Large File Storage to use a third party server

By default, the Git Large File Storage client stores large assets on the same server that hosts the Git repository. When Git LFS is enabled on your GitHub Enterprise Server instance, large assets are stored on the data partition in /data/user/storage.

如果在企业或仓库上禁用了 Git LFS,则用户� 法将 Git LFS 资产推送到 GitHub Enterprise Server 。

  1. Disable Git LFS on your GitHub Enterprise Server instance. For more information, see "Configuring Git Large File Storage for your enterprise."

  2. Create a Git LFS configuration file that points to the third party server.

    # Show default configuration
    $ git lfs env
    > git-lfs/1.1.0 (GitHub; darwin amd64; go 1.5.1; git 94d356c)
    > git version 2.7.4 (Apple Git-66)
    � 
    > Endpoint=https://GITHUB-ENTERPRISE-HOST/path/to/repo/info/lfs (auth=basic)
    � 
    # Create .lfsconfig that points to third party server.
    $ git config -f .lfsconfig remote.origin.lfsurl https://THIRD-PARTY-LFS-SERVER/path/to/repo
    $ git lfs env
    > git-lfs/1.1.0 (GitHub; darwin amd64; go 1.5.1; git 94d356c)
    > git version 2.7.4 (Apple Git-66)
    � 
    > Endpoint=https://THIRD-PARTY-LFS-SERVER/path/to/repo/info/lfs (auth=none)
    � 
    # Show the contents of .lfsconfig
    $ cat .lfsconfig
    [remote "origin"]
    lfsurl = https://THIRD-PARTY-LFS-SERVER/path/to/repo
  3. To keep the same Git LFS configuration for each user, commit a custom .lfsconfig file to the repository.

    $ git add .lfsconfig
    $ git commit -m "Adding LFS config file"
  4. Migrate any existing Git LFS assets. For more information, see "Migrating to a different Git Large File Storage server."

Migrating to a different Git Large File Storage server

Before migrating to a different Git Large File Storage server, you must configure Git LFS to use a third party server. For more information, see "Configuring Git Large File Storage to use a third party server."

  1. Configure the repository with a second remote.

    $ git remote add NEW-REMOTE https://NEW-REMOTE-HOSTNAME/path/to/repo
    � 
    $ git lfs env
    > git-lfs/1.1.0 (GitHub; darwin amd64; go 1.5.1; git 94d356c)
    > git version 2.7.4 (Apple Git-66)
    � 
    > Endpoint=https://GITHUB-ENTERPRISE-HOST/path/to/repo/info/lfs (auth=basic)
    > Endpoint (NEW-REMOTE)=https://NEW-REMOTE-HOSTNAME/path/to/repo/info/lfs (auth=none)
  2. Fetch all objects from the old remote.

    $ git lfs fetch origin --all
    > Scanning for all objects ever referenced...
    > ✔ 16 objects found
    > Fetching objects...
    > Git LFS: (16 of 16 files) 48.71 MB / 48.85 MB
  3. Push all objects to the new remote.

    $ git lfs push NEW-REMOTE --all
    > Scanning for all objects ever referenced...
    > ✔ 16 objects found
    > Pushing objects...
    > Git LFS: (16 of 16 files) 48.00 MB / 48.85 MB, 879.10 KB skipped

Further reading