关于 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
.
Users cannot push Git LFS assets to GitHub Enterprise Server if Git LFS is disabled on the enterprise or repository.
更多信息请参阅“关于 Git Large File Storage”、“大文件版本管理”以及 Git Large File Storage 项目站点。
Configuring Git Large File Storage for your enterprise
- 访问
https://HOSTNAME/enterprises/ENTERPRISE-NAME
,将HOSTNAME
替换为您的实例的主机名,将ENTERPRISE-NAME
替换为您的企业帐户的名称,找到您的企业帐户。
-
在企业帐户侧边栏中,单击 Settings(设置)。
-
Under " Settings", click Options.
-
在“Git LFS 访问权限”下,使用下拉菜单,然后单击 Enabled(已启用)或 Disabled(已禁用)。
为各个仓库配置 Git Large File Storage
注意: 每个仓库自动从拥有它的组织或用户继承默认设置。 如果仓库所有者已在其所有仓库上强制执行设置,则您不能覆盖默认设置。
- From an administrative account on GitHub Enterprise Server, click in the upper-right corner of any page.
- 在搜索字段中,输入仓库的名称,然后单击 Search(搜索)。
- 在搜索结果中,单击仓库名称。
- 在页面的右上角,单击 Admin(管理员)。
- 在左侧边栏中,单击 Admin(管理员)。
- 在“Git LFS”下,单击 Enable(启用)或 Disable(禁用)。
为用户帐户或组织拥有的每个仓库配置 Git Large File Storage
- From an administrative account on GitHub Enterprise Server, click in the upper-right corner of any page.
- 在搜索字段中,输入用户或组织的名称,然后单击 Search(搜索)。
- 在搜索结果中,单击用户或组织的名称。
- 在页面的右上角,单击 Admin(管理员)。
- 在左侧边栏中,单击 Admin(管理员)。
- 在“Git LFS”下,单击 Enable(启用)或 Disable(禁用)。
将 Git Large File Storage 配置为使用第三方服务器
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
.
Users cannot push Git LFS assets to GitHub Enterprise Server if Git LFS is disabled on the enterprise or repository.
-
Disable Git LFS on your GitHub Enterprise Server instance. For more information, see "Configuring Git Large File Storage for your enterprise."
-
创建指向第三方服务器的 Git LFS 配置文件。
# 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
-
为使各用户的 Git LFS 配置相同,请向仓库提交自定义
.lfsconfig
文件。$ git add .lfsconfig $ git commit -m "Adding LFS config file"
-
迁移任何现有的 Git LFS 资源。 更多信息请参阅“迁移到不同的 Git Large File Storage 服务器”。
迁移到其他 Git Large File Storage 服务器
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."
-
使用第二个远端配置仓库。
$ 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)
-
从旧远端提取所有对象。
$ 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
-
将所有对象推送到新远端。
$ 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