将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

感谢您的帮助 -欧文

解决方法

我认为在这种情况下,是否指定 --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/repository 的 GitLab 项目设置中启用 Allow force push 选项

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