Git 恢复到以前合并的分支提交,而不丢失任何版本

Git 恢复到以前合并的分支提交,而不丢失任何版本,git,git-flow,Git,Git Flow,我的提交历史记录是 A->B->C(头部) 如果我想恢复到B,而不丢失版本C。 (使所有数据与B相同) (但B和C合并提交) A->B->C->B(头部) 我使用git流开发我的项目 我想恢复到6450851E7A51F868DA414467B42B0C0C072718F5B9 并执行以下命令,但出现错误 我怎么能得到它 (develop)$ git revert 6450851e7a51f868da414467b42b0c072718f5b9 error: Commit 6450851e7a5

我的提交历史记录是

A->B->C(头部)

如果我想恢复到
B
,而不丢失版本
C
。 (使所有数据与
B
相同)

(但B和C合并提交)

A->B->C->B(头部)

我使用
git流
开发我的项目

我想恢复到
6450851E7A51F868DA414467B42B0C0C072718F5B9

并执行以下命令,但出现错误

我怎么能得到它

(develop)$ git revert 6450851e7a51f868da414467b42b0c072718f5b9
error: Commit 6450851e7a51f868da414467b42b0c072718f5b9 is a merge but no -m option was given.
fatal: revert failed


*   f831a96 - (HEAD, tag: 1.1, origin/master, master) Merge branch 'release/1.1' (7 days ago)
|\
| * 277bafc - Release 1.1 (7 days ago)
| *   57a4374 - Merge branch 'feature/add_expired_time_and_restore_sorting_cart_bug' into develop (7 days ago)
| |\
| | * 3866d1d - Remove the larger input field (7 days ago)
| | * 879c12e - Remove the insert new item at first function (7 days ago)
| | * bbd7b2b - remove the change password function (7 days ago)
| | * bc4a6fa - add expired time functionality (7 days ago)
| |/
| *   6450851 - Merge branch 'feature/readable_format' into develop (7 days ago)
| |\
| | * cac4083 - make the line space in table more dense (7 days ago)

首先,如果您有合并,那么您的提交历史要比
A->B->C
复杂得多

但是,希望
C
不是合并提交。如果这是真的,那么您希望运行:

git revert hash-of-commit-C

git revert
获取要撤消的提交的哈希,而不是要还原到的提交)。

要还原合并,需要告诉git合并提交的父级是要保留的主线:

git revert -m 1 6450851e7a51f868da414467b42b0c072718f5b9

您将在此处找到更多信息:

不幸的是,这是一个合并提交