You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
python/文档/git 清除所有历史记录.txt

42 lines
1.3 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

Note-git 常用命令
https://www.jianshu.com/p/0396c3662650
git 清除所有历史记录
有些时候git 仓库累积了太多无用的历史更改,导致 clone 文件过大。如果确定历史更改没有意义,可以采用下述方法清空历史,
1) 先 clone 项目到本地目录 (以名为 python 的仓库为例)
$ git clone https://gitee.com/littlehb/python.git
2) 进入 python 仓库,(cd python) 拉一个分支,比如名为 latest_branch
$ git checkout --orphan latest_branch
3) 添加所有文件到上述分支 (Optional)
$ git add -A
4) 提交一次
$ git commit -am "Initial commit."
5) 删除 master 分支
$ git branch -D master
6) 更改当前分支为 master 分支
$ git branch -m master
7) 将本地所有更改 push 到远程仓库
$ git push -f origin master
8) 关联本地 master 到远程 master
$ git branch --set-upstream-to=origin/master
注意:对 gitee 用户,因为 gitee 目前限制单个仓库大小为 1024 MB清除完历史记录后还要去项目主页 Settings 下做一下 Git GC.
完。
https://www.freesion.com/article/5635841380/
https://www.cnblogs.com/verdent/p/13736662.html
ssh-keygen -t rsa -C "10402852@qq.com" -f C:/Users/Administrator/.ssh/id_rsa_18686619970