:::info 相关的两个问题:

  1. git checkout --orphan newBranch
  2. git add -A # Add all files and commit them
  3. git commit
  4. git branch -D master # Deletes the master branch
  5. git branch -m master # Rename the current branch to master
  6. git push -f origin master # Force push master branch to github
  7. git gc --aggressive --prune=all # remove the old files

Deleting .git/ always causes huge issues when I have submodules. Using git rebase --root would somehow cause conflicts for me (and take long since I had a lot of history).

关于最后一点,评论区里有回答到:

Git will keep the old files around for a while, to get rid of them run git gc --aggressive --prune=all .

需要注意

这里的 git add -A 的理解可以看这里https://www.cnblogs.com/e0yu/p/8608674.html,看上去在2.x版本中,与 git add . 无异。