場景
把舊專案提交到Git上,但是會有一些歷史記錄,這些歷史記錄中可能會有專案密碼等敏感資訊。如何刪除這些歷史記錄,形成一個全新的倉庫,並且保持程式碼不變呢?
操作
Checkout
git checkout --orphan latest_branch
Add all the files
git add -A
Commit the changes
git commit -am "commit message"
Delete the branch
git branch -D master
Rename the current branch to master
git branch -m master
Finally, force update your repository
git push -f origin master