把舊項目提交到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