首页 > 解决方案 > 将 BFG 的结果存储到 Gitlab 中的新项目中

问题描述

我已经成功(我认为!)从使用 BFG 镜像到我的本地驱动器上的 gitlab 项目中删除了大文件。我不想替换现有的 gitlab 项目(出于安全原因),而是想推到一个新的测试 gitlab 项目。这是我到目前为止成功完成的命令:

git clone --mirror git@git.domain.com:architecture-team/IOMobile.git
java -jar bfg.jar --strip-blobs-bigger-than 100M IOMobile.git/
cd IOMobile.git
git reflog expire --expire=now --all
git gc --prune=now --aggressive

这些命令似乎已经成功了,现在我如何将原点重置为:

git@git.domain.com:architecture-team/testiomobile.git

...然后将镜像推入新项目?我不确定如何在镜像上重置原点,并想确保我不会更改原始项目。

我只是做一个简单的

git push

还是我需要

git push --mirror

感谢您的帮助-欧文

标签: gitlabgit-rewrite-historybfg-repo-cleaner

解决方案


我认为在这种情况下,您是否指定--mirror都没关系。由于您已经使用--mirror标志克隆了它,因此普通的 git push 将更新远程服务器上的所有引用。这也在 bfg 文档中有所描述: https ://rtyley.github.io/bfg-repo-cleaner/

但是你可能会遇到一个问题。如果您在推送时看到此错误消息:

remote: GitLab: You are not allowed to force push code to a protected branch on this project.

然后您必须在 URL https://git.domain.com/architecture-team/testiomobile/-/settings/repositoryAllow force push的 GitLab 项目设置中启用选项

推送后,您应该Allow force push再次禁用。


推荐阅读