git merge --no-commit vs git cherry-pick --no-commit

前端 未结 2 1994
深忆病人
深忆病人 2021-02-06 22:18

Is there any difference between git merge --no-commit and git cherry-pick --no-commit?

And is there any difference in history if I commit after

2条回答
  •  后悔当初
    2021-02-06 22:39

    If you commit after git merge --no-commit, you'll actually get a merge commit. Whereas after a git cherry-pick --no-commit you'll get a commit with a single parent.

    Hence, yes, there is a difference between those two commands.

    In particular if you have something like

    A -- B -- C
     \        L HEAD
      \
       -- D -- E
    

    If you cherry-pick commit E, you won't get modifications of commit D. Whereas if you merge, you'll get both.

提交回复
热议问题