BFG Repo-Cleaner声明我的github存储库不是有效的Git存储库

yx2lnoni  于 2022-12-17  发布在  Git
关注(0)|答案(4)|浏览(111)

这是a previous question on Stackoverflow的后续问题。
我尝试过从本地git历史记录中删除大文件,但工具(BFG Repo-Cleaner)建议in this question声明我的私有GitHub仓库不是有效的git仓库。
我使用的命令是:

java -jar bfg-1.12.12.jar  --strip-blobs-bigger-than 99M https://github.com/name/repo.git

最终导致:

Aborting : https://github.com/name/repo.git is not a valid Git repository.

我找不到解决方案。该工具是否与私有或https GitHub仓库不兼容?我该如何使用替代工具git-filter-branch,从本地git历史记录中删除所有大于99 MB的文件?
这个项目大约有6 MB大,到目前为止只提交了大约50次,没有其他人在处理它。

8dtrkrch

8dtrkrch1#

指向 * 本地 * 拷贝,而不是远程拷贝。
你已经把你的GitHub URL给了这个工具,但是他们网站上的用法部分说你应该从你的仓库的本地副本开始工作:

用法

首先使用--mirror标志克隆一个repo的新副本:

$ git clone --mirror git://example.com/some-big-repo.git

这是一个裸存储库,这意味着你的普通文件将不可见,但它是你的存储库的Git数据库的一个 * 完整 * 副本,此时你应该对其进行备份以确保你不会丢失任何东西。
现在您可以运行BFG来清理存储库了:

$ java -jar bfg.jar --strip-blobs-bigger-than 100M some-big-repo.git

在那个页面上还有很多其他的好内容;我建议你在再试一次之前把整本书读一遍。

vuktfyat

vuktfyat2#

我已使用以下命令修复了此问题:

第一步

cd some-big-repo.git

第二步

java -jar path/bfg.jar --strip-blobs-bigger-than 100M

如果您在repo目录中,则无需明确提及repo名称,它将自动检测repo并完成其工作。

wfypjpf4

wfypjpf43#

你应该记住,在git中,你对历史所做的一切都必须在本地完成,然后,一旦你满意了,就可以通过推送到远程仓库来发布。
所以,在这里你必须给予你的本地存储库的路径...

dfuffjeb

dfuffjeb4#

非常简单,只需在命令行中执行以下操作:

#Change directory to the root of your git repo
cd C:\Projects\MyRepositoryFolder

#Drag the bfg.jar file (or what ever the .jar file name you have) into the repo folder you changed directory to (above). Then once done run
java -jar bfg.jar -b 100M

相关问题