git push之后回滚到某个版本

文章目录
背景
针对于我的需求(希望将后续的commit冲掉)
背景
因为粗心在主分支上修改了代码,push了上去,污染了主分支,希望将主分支之后的修改回滚,包括提交记录,就是远程的记录中回到希望回到的版本,保持干净。

git push -f 可以做到,会冲掉所有的commit,如果git push -f 之后希望回滚:http://blog.sina.com.cn/s/blog_66cd08930102x0ln.html

如果不希望将后面的commit全部冲刷掉,https://blog.csdn.net/gomeplus/article/details/78241070

针对于我的需求(希望将后续的commit冲掉)
回退命令:

$ git reset --hard HEAD^ 回退到上个版本
$ git reset --hard HEAD~3 回退到前3次提交之前,以此类推,回退到n次提交之前
$ git reset --hard commit_id 退到/进到 指定commit的sha码

强推到远程:

$ git push origin HEAD --force

https://www.cnblogs.com/spring87/p/7867435.html
 

猜你喜欢

转载自blog.csdn.net/huangpeigui/article/details/105101238