How to copy commits from one branch to another?

前端 未结 9 1457
猫巷女王i
猫巷女王i 2020-11-27 09:08

I\'ve got two branches from my master:

  • v2.1: (version 2) I\'ve been working on for several months
  • wss: that I create
9条回答
  •  遥遥无期
    2020-11-27 09:11

    Here's another approach.

    git checkout {SOURCE_BRANCH}               # switch to Source branch.
    git checkout {COMMIT_HASH}                 # go back to the desired commit.
    git checkout -b {temp_branch}              # create a new temporary branch from {COMMIT_HASH} snapshot.
    git checkout {TARGET_BRANCH}               # switch to Target branch.
    git merge {temp_branch}                    # merge code to your Target branch.
    git branch -d {temp_branch}                # delete the temp branch.
    

提交回复
热议问题