• git 清除所有历史记录


    有些时候,git 仓库累积了太多无用的历史更改,导致 clone 文件过大。如果确定历史更改没有意义,可以采用下述方法清空历史,

    1) 先 clone 项目到本地目录 (以名为 mylearning 的仓库为例)

    $ git clone git@gitee.com:badboycoming/mylearning.git

    2) 进入 mylearning 仓库,拉一个分支,比如名为 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.

    完。

  • 相关阅读:
    oracle操作。
    python 多行对应元素求和
    matplotlib 画饼图
    ggplot2 图例及分页参数
    python(3)跳过第一行(多行)读入数据
    seqtk抽取测序数据
    数据库命令补全工具mycli
    取色网站
    perl 转置矩阵
    python 调用系统软件
  • 原文地址:https://www.cnblogs.com/gaowengang/p/10955871.html
Copyright © 2020-2023  润新知