shenmo的世界

删除所有git历史记录

原文链接:https://blog.csdn.net/yc1022/article/details/56487680

1.Checkout

git checkout –orphan latest_branch

  1. Add all the files

    git add -A

  2. Commit the changes

    git commit -am “commit message”

  3. Delete the branch

    git branch -D master

5.Rename the current branch to master

git branch -m master

6.Finally, force update your repository

git push -f origin master

————————————————

版权声明:本文为CSDN博主「yanchengyc」的原创文章,遵循CC 4.0 BY-SA版权协议

方便直接使用:

 git checkout --orphan latest_branch
 git add -A
 git commit -am "重置仓库到最新一次commit"
 git branch -D master
 git branch -m master
 git push -f origin master

注意:Gitee上还需要进行储存库GC来清理占用空间