因累积太多无法提交到 github,如何清除历史变更记录?
某草草
某草草 2017-05-02 09:31:58
0
2
600

如题,累积有半年没 push 到 github 了,由于里面有几个 jar 没忽略,越来越多,push 后会报:

Counting objects: 4779, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (3903/3903), done.
error: RPC failed; result=56, HTTP code = 200 | 14.92 MiB/s
fatal: The remote end hung up unexpectedlyMiB | 158.00 KiB/s
Writing objects: 100% (4779/4779), 628.84 MiB | 152.00 KiB/s, done.
Total 4779 (delta 2353), reused 3 (delta 0)
fatal: The remote end hung up unexpectedly
Everything up-to-date

搜了一些方法,像什么换 ssh 之类,都无效,请问有什么简单办法抛弃掉历史记录,只把当前的版本 push 上去?

实在没办法只好重新 clone 再覆盖,但线上也有几百兆,能有什么命令参数简单抛弃掉就最好了。


找到一个办法 https://www.kernel.org/pub/software/scm/git/docs/git-filter-branch.html 可以清理历史,目前正尝试,OK 后再来续写。

某草草
某草草

reply all(2)
伊谢尔伦

I finally found a simple way. Using the filter-branch command that comes with git can filter and delete, but it is too slow. I ran it all night and it didn't end, stuck at 98% progress. Later, I found the BFG Repo-Cleaner tool and deleted it within a few minutes. The size of the .git directory was reduced from about 2.9G to 70M. I deleted all tar.gz, zip, jar, war, etc. submitted in the past. Leave the source code behind and finally push it to github.

The specific execution process is:

bfg --delete-files *.tar.gz # 后面的文件名匹配可换成自己要删除的文件名
git reflog expire --expire=now --all
git gc --prune=now --aggressive
git push --all --force
git push --all --tags --force
大家讲道理

Rebase, -f when pushing

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!