Git: How to revert a merge commit that's already pushed to remote branch?

git revert commit-hash-value alone won’t work. -m must be specified, and I’m pretty confused about it.

See details:
这里写图片描述

The -m option specifies the parent number. This is because a merge commit has more than one parent, and Git does not know automatically which parent was the mainline, and which parent was the branch you want to un-merge.

When you view a merge commit in the output of git log, you will see its parents listed on the line that begins with Merge:
这里写图片描述

这里写图片描述

In this situation, git revert 4cb43c6 -m 1 will get you the tree as it was in 336a48b, and git revert 4cb43c6 -m 2 will reinstate the tree as it was in b75a5d7..

what is parent number?

links:
https://git-scm.com/blog/2010/03/02/undoing-merges.html
http://www.gitguys.com/topics/git-object-commit/

revert vs reset
http://yijiebuyi.com/blog/8f985d539566d0bf3b804df6be4e0c90.html
http://blog.csdn.net/hudashi/article/details/7664460

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值