How can I selectively merge or pick changes from another branch in Git?

前端 未结 25 1615
慢半拍i
慢半拍i 2020-11-22 02:53

I\'m using Git on a new project that has two parallel -- but currently experimental -- development branches:

  • master: import of existing codebase pl
25条回答
  •  臣服心动
    2020-11-22 03:20

    There is another way to go:

    git checkout -p
    

    It is a mix between git checkout and git add -p and might quite be exactly what you are looking for:

       -p, --patch
           Interactively select hunks in the difference between the 
           (or the index, if unspecified) and the working tree. The chosen
           hunks are then applied in reverse to the working tree (and if a
            was specified, the index).
    
           This means that you can use git checkout -p to selectively discard
           edits from your current working tree. See the “Interactive Mode”
           section of git-add(1) to learn how to operate the --patch mode.
    

提交回复
热议问题