如题,累积有半年没 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 后再来续写。
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:
Rebase, -f when pushing