git revert< hash>由于合并而不允许,但没有-m选项被给出 [英] git revert <hash> not allowed due to a merge but no -m option was given

查看:1894
本文介绍了git revert< hash>由于合并而不允许,但没有-m选项被给出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我正在使用以下命令:

p>

  git revert c14609d74eec3ccebafc73fa875ec58445471765 

但是,我收到以下信息:
$ b


错误:提交c14609d74eec3ccebafc73fa875ec58445471765是一个合并,但没有给出-m选项。

致命:恢复失败


作为新的git用户,请您解释发生了什么&我必须做些什么来解决这个问题。



我想恢复到这个特定的提交( c14609d74eec3ccebafc73fa875ec58445471765 ),我在运行时发现 git log

解决方案

合并提交,并且git不知道要恢复到哪个父级。 -m 允许我们选择要选择的父项。看到合并提交并记下你想要去哪个父母。父信息可以在 git log 中看到,例如:

lockquote
commit d02ee0f2179def10277f30c71c5d6f59ded3c595



合并:dd3a24c 2462a52

并运行:

  git revert< hash> -m 1 

其中 1 表示父母号码1



如果您试图将还原为那个提交,请执行:

  git reset --hard< hash> 

了解 git revert git reset 从文档中选择,然后决定您想要哪一个。 git revert 是更安全的选项,但并没有真正做到你想要的。它只是恢复(一组)提交的更改。 git reset 使您可以移至历史记录中的特定提交,并将重写您的历史记录。


I am trying to revert to a certain 'hash' number in git, by using the 'revert' command.

I am using the following command:

git revert c14609d74eec3ccebafc73fa875ec58445471765

But, I am getting the following returned:

error: Commit c14609d74eec3ccebafc73fa875ec58445471765 is a merge but no -m option was given.
fatal: revert failed

As a new git user, please can you explain what is happening & what I have to do to resolve this.

I want to revert back to this certain commit (c14609d74eec3ccebafc73fa875ec58445471765) that I see when running git log.

解决方案

You are trying to revert a merge commit, and git doesn't know which parent to revert to. The -m allows us to choose which parent to choose. See the merge commit and note down which parent you want to go to. The parent information can be seen in git log, for example:

commit d02ee0f2179def10277f30c71c5d6f59ded3c595

Merge: dd3a24c 2462a52

and run:

git revert <hash> -m 1

where 1 indicates parent number 1.

If you are trying to revert to that commit, do:

git reset --hard <hash>

Understand the difference between git revert and git reset from the docs and decide which one you want. git revert is the safer option, but doesn't really do what you want. It just reverts the changes of a (set of) commit. git reset makes you move to a particular commit in history, and will rewrite your history.

这篇关于git revert&lt; hash&gt;由于合并而不允许,但没有-m选项被给出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆