有的时候想把项目之前提交的记录给清除,该如何做呢?

  1. 先把项目 Clone 到本地

    git clone 项目地址

  2. Checkout

    git checkout --orphan latest_branch

  3. Add all the files

    git add -A

  4. Commit the changes

    git commit -am "commit message"

  5. Delete the branch

    git branch -D main

  6. Rename the current branch to main

    git branch -m main

  7. Finally, force update your repository

    git push -f origin main

来源:https://stackoverflow.com/questions/13716658/how-to-delete-all-commit-history-in-github