git仓库删除所有提交历史记录,成为一个干净的新仓库

2018-05-03 程序代码 1368 阅读 0 评论

把旧项目提交到git上,但是会有一些历史记录,这些历史记录中可能会有项目密码等敏感信息。如何删除这些历史记录,形成一个全新的仓库,并且保持代码不变呢?
1.Checkout

git checkout --orphan latest_branch
  1. Add all the files
git add -A
  1. Commit the changes
git commit -am "commit message"
  1. 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

本文链接:https://blog.clang.cn/820.html

版权声明:转载请注明出处。

评论 (0)

评论已关闭