Rebase a single Git commit

后端 未结 5 1276
一个人的身影
一个人的身影 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:24

    Here's another option:

    1. Make sure you have a remote with a copy of the feature branch
    2. Delete the local feature branch
    3. Create and checkout a new branch with the same name as the old feature branch you just deleted off of master
    4. cherry-pick the one commit from the remote copy of the feature branch you want.

    Commands look like:

    git checkout Feature-branch
    git push -u origin HEAD
    git checkout master
    git branch -D Feature-branch
    git checkout -b Feature-branch
    git cherry-pick HASH-OF-XX
    

    It's not a rebase command no, but it's a rebase in spirit.

提交回复
热议问题