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

来源:互联网 发布:mac桌面文件 编辑:程序博客网 时间:2024/06/10 06:12

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

1.Checkout   git checkout --orphan latest_branch2. Add all the files   git add -A3. Commit the changes   git commit -am "commit message"4. Delete the branch   git branch -D master5.Rename the current branch to master   git branch -m master6.Finally, force update your repository   git push -f origin master

参考stackoverflow

0 0
原创粉丝点击