Git: Make one branch exactly like another

后端 未结 4 726
孤独总比滥情好
孤独总比滥情好 2021-01-21 04:29

I am relatively new to Git, and I\'m still not very comfortable with it. Right now, I\'m looking for the command/options/magic that can make the current branch look like anothe

4条回答
  •  轮回少年
    2021-01-21 05:14

    The accepted answer ("Branches are just pointers ...") is no good for me, because not only do I need my branch to look like another branch - I need to do so by only apply another commits (not losing any of the commits in the current history of my branch).

    I liked this approach for making branch A look like branch B:

    git checkout B git diff A > patch_to_make_A_like_B git checkout A git apply patch_to_make_A_like_B

    (And rm patch_to_make_A_like_B at the end.)

提交回复
热议问题