【问题标题】:Removing large file from git history?从 git 历史记录中删除大文件?
【发布时间】:2014-06-19 16:53:25
【问题描述】:

我们有一个远程 git 存储库,其中没有文件大小限制,我们已将 300MB 推入其中。然后我们意识到了这一点,然后从存储库中删除了该文件。

同时将相同的存储库添加到 github,当我们尝试将更改推送到 github 时,我们会收到大文件大小错误。

remote: error: File dir/filename is 312.27 MB; this exceeds GitHub's file size limit of 100 MB

为了解决这个问题,我尝试使用How to remove/delete a large file from commit history in Git repository? 建议的交互式 git rebase 解决方案,但在 rebase 操作结束时,当我执行 git status

[18:10:35] $ git status
On branch master
Your branch and 'origin/master' have diverged,
and have 8 and 24 different commits each, respectively.
  (use "git pull" to merge the remote branch into yours)

如果我使用 git pull 那么我删除的所有更改都会被带回 git 存储库。我该如何解决这个问题?

【问题讨论】:

    标签: git github git-branch git-merge rebase


    【解决方案1】:

    如果我猜对了,在变基后你想做git push -f origin 而不是git pull。这会按预期重写远程存储库历史记录。

    注意 强制推送到共享存储库可能会擦除其他人的更改,并且只能在与有权访问的每个人协商后进行。 此外,我建议确保您将来可以访问 origin/master 的废弃历史记录(通过标记它或类似的东西),至少在每个人都同意变基工作正常之前。

    【讨论】:

      猜你喜欢
      • 2020-03-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-10-01
      • 1970-01-01
      • 1970-01-01
      • 2019-03-17
      相关资源
      最近更新 更多