sourcetree对merge进行回滚操作
滚回merge如果直接通过sourcetree操作,会有如下错误提示:
git -c diff.mnemonicprefix=false -c core.quotepath=false --no-optional-locks revert --no-edit f03a431a31ea713ebc4201ea41f2086caead22a5
error: commit f03a431a31ea713ebc4201ea41f2086caead22a5 is a merge but no -m option was given.
fatal: revert failed
这个时候需要通过终端敲命令来处理,先通过git log查看merge的记录(ctrl-z退出Log):
$ git log
commit f03a431a31ea713ebc4201ea41f2086caead22a5 (HEAD -> dev-cashsama, origin/dev-cashsama)
Merge: aee2c726 2e34d810
Author: xxx
Date: Mon Oct 25 17:58:16 2021 +0800
Merge branch 'dev-logging-trace' into dev-cashsam
这条记录对应sourcetree里的记录:
f03a431a31ea713ebc4201ea41f2086caead22a5 就是 merge记录, 而aee2c726是当前分支merge前面的提交, 2e34d810 是另外被merge过来的分支是最后一次提交记录。 这个时候需要选择到底revert到哪个最后一次提交(通过-m命令,这里选择当前分支的最后一次提交)
$ git revert f03a431 -m 1
[dev-cashsama 1fea9d34] Revert "Merge branch 'dev-logging-trace' into dev-cashsama"
5 files changed, 6 insertions(+), 20 deletions(-)
执行revert后会让你写提交说明, 默认就 press Esc and then ZZ
这样就执行完了,在sourcetree上就是多了一条revert记录: