如何将不同的git历史记录推送到不同的存储库? [英] How might one push a different git history to different repositories?

查看:92
本文介绍了如何将不同的git历史记录推送到不同的存储库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

TL; DR:是否存在一种有效的方法,可以将仅从现在开始"推送到镜像另一个的git存储库,而不会丢失同一项目的其他镜像上的历史记录?

我有一个具有一定规模(即胖")的项目,该项目被推送到三个不同的存储库中.小组内部赞助"该项目,一个是Sourceforge,一个是GitHub.

I have a project of a certain scale (that is to say, "fat") that is being pushed to three different repositories; one internal to a group "sponsoring" the project, one being Sourceforge, and one being GitHub.

不幸的是,在该项目公开"到GitHub之前,一些大型AI"knowledgebase"类型的数据文件已作为CSV文件添加到存储库中;超过GitHub的大小限制(软限制为50MiB,硬限制为100MiB)

Unfortunately, before this project "went public" to GitHub, some large AI "knowledgebase" type data files were added to the repository as CSV files; several over GitHub's size limit (soft limit 50MiB, hard limit 100MiB)

一旦意识到大小问题,我将删除文件并推送BZ2文件,这些文件将在构建过程中(一旦将文件正确编译)扩展回Makefile,这些文件将被编译到系统的状态.

Once we realised the size issues, I've removed the files and pushed BZ2 files that the Makefile will (once I get around to doing it right) expand back out during the build process, when the files are compiled into the system's state.

现在,内部存储库和Sourceforge是同步的,但是即使HEAD中没有文件,我也无法推送到GitHub.

Now, the internal repository and the Sourceforge are in sync, but even though the files are absent in the HEAD, I cannot push to GitHub.

清除.git控制文件(啊,还有子模块!再次正确设置真是一件痛苦的事……)然后重新开始,有没有办法像这样

Short of wiping out the .git control files (argh, and there are submodules! What a pain to set up properly again…) and starting over, is there a way to so something like

  git push origin BRANCH
  git push sourceforge BRANCH
  git push github from-xyzzy-to-HEAD:BRANCH

我最好的猜测是使用

  git push github 320ce5..HEAD:BRANCH

但是我明白了 错误:src refspec 320ce5..HEAD不匹配任何内容. 错误:无法将某些参照推送到…

but I get error: src refspec 320ce5..HEAD does not match any. error: failed to push some refs to …

(注意:320ce5是最新提交,删除了有问题的CSV文件的提交.因此它可能是HEAD.我还尝试添加一个无用的空文件,然后将其删除以伪造"一些历史记录,以防万一.问题,但没有帮助.)

(Note: 320ce5 is the latest commit, the one with the offending CSV files removed. So it's presumable = HEAD. I also tried adding a useless empty file and then removing it to "fake" some history in case that was the issue, but it didn't help.)

我开始相信答案是否",我应该存档先前的存储库状态,咬紧牙关,然后重新开始,这确实不应该伤害任何人的感觉,但这是一个麻烦.

I'm starting to believe that the answer is "no," and I should just archive the prior repository state, bite the bullet, and start over, which really shouldn't hurt anyone's feelings too much, but it is an hassle.

推荐答案

这不是直接答案,但可能对您有用.使用 BFG

This is not direct answer, but maybe useful for you. Drop big files from repo without cutting whole history with BFG

bfg --strip-blobs-bigger-than 1M --replace-text banned.txt repo.git

干净的仓库

git gc --prune=now --aggressive

并将更改后的仓库推送到仓库

and push changed repo to repository with

git push --force --all

也可以通过 git-filter-branch

相关问题:

  • Update a development team with rewritten Git repo history, removing big files
  • Git repo still huge after large files removed from repository history

这篇关于如何将不同的git历史记录推送到不同的存储库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆