git cherry-pick or merge specific directory from another branch

后端 未结 5 1236
無奈伤痛
無奈伤痛 2020-12-31 01:00

I\'ve seen different posts on StackOverflow that explain cherry picking a bit, but the comments in their code aren\'t very specific as to what\'s a branch and what\'s a dire

5条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-31 01:36

    Note:

    • git cherry-pick is about applying a full commit (or commits) to another branch. There is no notion of "path".
    • git checkout is about updating the working tree (and HEAD if no path is specified, effectively switching branches)

      git checkout [-p|--patch] [] [--] ...
      

    When or --patch are given, git checkout does not switch branches.
    It updates the named paths in the working tree from the index file or from a named (most often a commit). The argument can be used to specify a specific tree-ish (i.e. commit, tag or tree) to update the index for the given paths before updating the working tree.

    Your git checkout dev -- tools/my-tool updates a specific path, but it isn't a "merge" or a "git cherry-pick".

提交回复
热议问题