Git清空所有commit记录方法

说明:例如将代码提交到git仓库,将一些敏感信息提交,所以需要删除提交记录以彻底清除提交信息,以得到一个干净的仓库且代码不变

  1. Checkout
1
git checkout –-orphan latest_branch
  1. Add all the files
1
git add -A
  1. Commit the changes
1
git commit -am "commit message"
  1. Delete the branch
1
git branch -D master
  1. Rename the current branch to master
1
git branch -m master
  1. Finally, force update your repository
1
git push -f origin master
作者

雾非雾的情思

发布于

2019-04-25

更新于

2023-03-05

许可协议

评论