场景:项目部署发布后发现有问题,需要回滚到某一个commit,再重新发布
关键点:先将本地分支退回到某个commit,删除远程分支,再重新推送本地分支
操作步骤:
1、git checkout the_branch // 切换到某个分支
2、git pull // 获取最新代码
3、git branch the_branch_backup // 备份这个分支
4、git push origin the_branch_backup // 将备份分支推送到远程仓库
5、git reset --hard the_commit_id // 把the_branch本地回滚到某个提交
6、git push origin :the_branch // 删除远程 the_branch,注意有【:】
7、git push origin the_branch // 将回滚后的本地分支重新推送到远程仓库
8、git push origin :the_branch_backup // 删除远程备份分支