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