有些时候,git 仓库累积了太多无用的历史更改,导致 clone 文件过大。如果确定历史更改没有意义,可以采用下述方法清空历史,
cnblog-tool
的仓库为例) $ git clone git@gitee.com:makalochen/cnblog-tool.git
cnblog-tool
仓库,拉一个分支,比如名为 latest_branch$ git checkout --orphan latest_branch
$ git add -A
$ git commit -am "Initial commit."
$ git branch -D master
$ git branch -m master
$ git push -f origin master
$ git branch --set-upstream-to=origin/master
注意:对 gitee 用户,因为 gitee 目前限制单个仓库大小为 1024 MB,清除完历史记录后,还要去项目主页 Settings 下做一下 Git GC.
原文:https://www.cnblogs.com/makalochen/p/14526012.html