Rebase a single Git commit

后端 未结 5 1297
一个人的身影
一个人的身影 2020-12-22 18:00

Is there a way to rebase a single commit from a branch onto another branch?

I have this branch structure:

-- -- -- -- -- (Master)
            \\
           


        
5条回答
  •  长情又很酷
    2020-12-22 18:29

    git rebase --onto master branch~1 branch 
    

    This says "rebase the range of commits between last-before-branch and branch (that is, XX commit) on the tip of master branch"

    After this operation branch tip is moved on commit XX, so you want to set it back with

    git checkout branch
    git reset --hard branch@{1}^
    

    Which says "reset the branch tip to the commit before its previous state"

    So a cherry pick is a simpler solution...

提交回复
热议问题