How to do a non-fast-forward git merge to a branch that isn't checked out?

前端 未结 5 1838
误落风尘
误落风尘 2021-01-04 11:31

I\'m on branch a. I want to merge branch b into branch c. The merge is not a fast-forward, but it also doesn\'t require manual resolut

5条回答
  •  半阙折子戏
    2021-01-04 12:29

    This answer explains a workaround that you can try.

    No, there is not. A checkout of the target branch is necessary to allow you to resolve conflicts, among other things (if Git is unable to automatically merge them).

    However, if the merge is one that would be fast-forward, you don't need to check out the target branch, because you don't actually need to merge anything - all you have to do is update the branch to point to the new head ref. You can do this with git branch -f:

    git branch -f branch-b branch-a
    Will update branch-b to point to the head of branch-a.

提交回复
热议问题