search

Home  >  Q&A  >  body text

hg - [git]如果把分支a合并到分支b中,想从b中还原a改过的内容,怎么办?

如果用mercurial,只能到b分支中硬还原代码了。

git有智能的方式吗?

黄舟黄舟2764 days ago723

reply all(2)I'll reply

  • 黄舟

    黄舟2017-04-22 09:02:08

    "Want to restore the changed content of a from b", if you want to undo the branch merge operation, please trygit reset/revert {commit}

    You can use git reflog to check the HEAD pointer changes first, such as:

    de51e3d HEAD@{0}: merge nnn: Fast-forward
    4430e82 HEAD@{1}: checkout: moving from nnn to master
    de51e3d HEAD@{2}: commit: commit2
    4430e82 HEAD@{3}: checkout: moving from master to nnn
    4430e82 HEAD@{4}: commit (initial): test
    

    Then for example git reset HEAD@{2} return to a certain submission

    reply
    0
  • 伊谢尔伦

    伊谢尔伦2017-04-22 09:02:08

    You can directly make a new branch for the commit before merging, so nothing will be lost

    reply
    0
  • Cancelreply