如果不小心提交github提交错了,而 --amend 也不能修改提交者的信息,可以通过尝试下面的方式
Checkout
bash1git checkout --orphan <latest_branch>Add all the files
bash1git add -ACommit the changes
bash1git commit -am "commit message"Delete the branch
bash1git branch -D mainRename the current branch to main
bash1git branch -m mainFinally, force update your repository
bash1git push -f origin main
缺点是:所有该分支的提交记录都将被删除
Reference