[英]How to revert back my GitHub commit to the previous one?
要刪除新提交的所有痕跡,您需要將分支重置回不包含該內容的早期 state(提交)。 如果您只是刪除第一個最近的提交,您可以這樣做
# switch to your branch
git switch your-branch
# reset your branch hard to point to the (1) most recent commit
git reset --hard your-branch~1
# push the new state of your branch to the server forcefully
git push your-remote your-branch --force-with-lease
您可以使用以下兩個命令刪除最后一次提交,並強制 github 與您的匹配。
git reset --hard HEAD^
git push origin -f
如果第二個命令不起作用,請嘗試
git push --force origin main
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.