把旧项目提交到Git上,可是会有一些历史记录,这些历史记录中可能会有项目密码等敏感信息。如何删除这些历史记录,造成一个全新的仓库,而且保持代码不变呢?git
Checkoutcode
git checkout --orphan latest_branch
Add all the filesit
git add -A
Commit the changesast
git commit -am "commit message"
Delete the branchtest
git branch -D master
Rename the current branch to masterdate
git branch -m master
Finally, force update your repositoryfile
git push -f origin master