回退
1
2git log //查看提交的历史
git reset --hard $要回退的commit号切换到临时分支推送并删除原分支
1
2
3
4git checkout -b temp // 新建临时分支并切换
git push origin temp:temp // 将代码push到temp分支
git push origin --delete main // 删除远端分支main,此处注意如果要删除的远端分支为默认分支则不可删除,需将默认分支切换到其他分支
git branch -d main // 删除本地分支main新建并切换回原分支并删除临时分支
1
2
3
4git checkout -b main // 新建本地分支main并切换
git push origin main // 提交分支main到远端
git branch -d temp // 删除本地临时分支
git push origin --delete temp // 删除远端临时分支,此处注意如果要删除的远端分支为默认分支则不可删除,需将默认分支切换到其他分支github切换默认分支:
进入对应repo → Settings → Branches → Switch to another branch
If the images or anything used in the blog infringe your copyright, please contact me to delete them. Thank you!