此版本的 GitHub Enterprise 已停止服务 2021-09-23. 即使针对重大安全问题,也不会发布补丁。 要获得更好的性能、改进的安全性和新功能,请升级到 GitHub Enterprise 的最新版本。 如需升级方面的帮助,请联系 GitHub Enterprise 支持

About large files on GitHub

GitHub Enterprise Server limits the size of files you can track in regular Git repositories. Learn how to track or remove files that are beyond the limit.

About size limits on GitHub Enterprise Server

GitHub Enterprise Server limits the size of files allowed in repositories. 如果尝试添加或更新大于 50 MB 的文件,您将从 Git 收到警告。 更改仍将成功推送到仓库,但您可以考虑删除提交,以尽量减少对性能的影响。 更多信息请参阅“从仓库的历史记录中删除文件”。

注:如果您通过浏览器将文件添加到仓库,该文件不得大于 25 MB。 更多信息请参阅“添加文件到仓库”。

默认情况下, GitHub Enterprise Server 阻止超过 100 MB 的推送。 但站点管理员可为您的 您的 GitHub Enterprise Server 实例 配置不同的限制。 For more information, see "Setting Git push limits."

To track files beyond this limit, you must use Git Large File Storage (Git LFS). For more information, see "About Git Large File Storage."

If you need to distribute large files within your repository, you can create releases on 您的 GitHub Enterprise Server 实例 instead of tracking the files. 更多信息请参阅“分发大型二进制文件”。

Git is not designed to handle large SQL files. 要与其他开发者共享大型数据库,建议使用 Dropbox

从仓库的历史记录中删除文件

警告:这些步骤将从您的计算机和 您的 GitHub Enterprise Server 实例 上的仓库中永久删除文件。 如果文件很重要,请在仓库外部的目录中创建本地备份副本。

删除在最近未推送的提交中添加的文件

如果文件使用最近的提交添加,而您尚未推送到 您的 GitHub Enterprise Server 实例,您可以删除文件并修改提交:

  1. 打开 Terminal(终端)Terminal(终端)Git Bash
  2. 将当前工作目录更改为您的本地仓库。
  3. 要删除文件,请输入 git rm --cached
    $ git rm --cached giant_file
    # Stage our giant file for removal, but leave it on disk
  4. 使用 --amend -CHEAD 提交此更改:
    $ git commit --amend -CHEAD
    # Amend the previous commit with your change
    # Simply making a new commit won't work, as you need
    # to remove the file from the unpushed history as well
  5. 将提交推送到 您的 GitHub Enterprise Server 实例:
    $ git push
    # Push our rewritten, smaller commit

删除之前提交中添加的文件

如果在之前的提交中添加了文件,则需要将其从仓库历史记录中删除。 要从仓库历史记录中删除文件,可以使用 BFG Repo-Cleaner 或 git filter-branch 命令。 更多信息请参阅“从仓库中删除敏感数据”。

分发大型二进制文件

如果需要在仓库内分发大型文件,您可以在 您的 GitHub Enterprise Server 实例 上创建发行版。 发行版允许您打包软件、发行说明和指向二进制文件的链接,以供其他人使用。 更多信息请参阅“关于发行版”。