重設GitHub repository並移除所有commits


[1] 的回答,假設 repository 位於 ~/dev/myrepo

# 移除所有紀錄
$ cd ~/dev/myrepo
$ rm -rf .git
# 重新造git repository
$ git init
# 將所有檔案加入repository
$ git add .
$ git commit -m "initial commit"
# 重設GitHub上的repository,此動作不可復原,做之前請先再次確認
$ git remote add origin <url>
$ git push --force --set-upstream origin master

References:

[1]version control - How to reset a remote GIT repository to remove all commits? - Stack Overflow