删除 BitBucket 上的大文件
Remove large files on BitBucket
我不小心在 BitBucket 上提交了一个大文件。在低 ram 嵌入式系统上克隆存储库导致内存不足异常。
我会从服务器上删除这个巨大的文件,或者将历史记录本地导出到提交之前的修订版,然后再次将其推送到 BitBucket。
如何做到这一点?
此致,
安东尼奥
这是来自 BitBucket 的解决方案:
You should be able to reset to a commit prior to the one that
introduced this file with the command: git reset --hard HEAD~N where N
is the number of commits you want to take the head back. Please note
that this is a destructive operation, and it permanently deletes the
commits, so I would strongly advise that you take a backup before
executing this command on the repo. As a next step, you can then force
push your changes in the remote repo: git push --f In case this file
was pushed many commits back, and you don't want to delete these
commits and changes in other files introduced by them, you may also
want to consider using BFG to remove this file only from git history:
https://rtyley.github.io/bfg-repo-cleaner/ BFG rewrites your history
as well, but instead of deleting the commits, you would simply change
them to remove this large file from them. Again, a backup is advised
in this case as well.
编辑: 我从 BitBucket/Atlassian 工作人员 https://confluence.atlassian.com/bitbucket/maintaining-a-git-repository-321848291.html 收到了官方 link 。
我不小心在 BitBucket 上提交了一个大文件。在低 ram 嵌入式系统上克隆存储库导致内存不足异常。
我会从服务器上删除这个巨大的文件,或者将历史记录本地导出到提交之前的修订版,然后再次将其推送到 BitBucket。
如何做到这一点?
此致, 安东尼奥
这是来自 BitBucket 的解决方案:
You should be able to reset to a commit prior to the one that introduced this file with the command: git reset --hard HEAD~N where N is the number of commits you want to take the head back. Please note that this is a destructive operation, and it permanently deletes the commits, so I would strongly advise that you take a backup before executing this command on the repo. As a next step, you can then force push your changes in the remote repo: git push --f In case this file was pushed many commits back, and you don't want to delete these commits and changes in other files introduced by them, you may also want to consider using BFG to remove this file only from git history: https://rtyley.github.io/bfg-repo-cleaner/ BFG rewrites your history as well, but instead of deleting the commits, you would simply change them to remove this large file from them. Again, a backup is advised in this case as well.
编辑: 我从 BitBucket/Atlassian 工作人员 https://confluence.atlassian.com/bitbucket/maintaining-a-git-repository-321848291.html 收到了官方 link 。