Home  >  Q&A  >  body text

版本控制 - Git 多人开发,合并分支如何避免来回切换?

在多人开发中,要经常合并别人的分支到自己的分支中。
我的做法是先切换到他人的分支,然后拉下来到最新,再切换到我自己的分支。最后合并他人的分支到我自己的分支。每次都要来回切换。感觉很麻烦。有更好的办法吗?

PHP中文网PHP中文网2727 days ago638

reply all(4)I'll reply

  • 给我你的怀抱

    给我你的怀抱2017-05-02 09:31:04

    It stands to reason that under normal circumstances, there is no situation where you merge with other people's branches, because there should only be one branch on the remote end (server side) (distinguish between development version, release version, etc.), and it should be cloned locally by multiple people. The remote branch will be pushed to this branch after the modification is completed. If there is a conflict in the push (someone else modified the remote branch first), pull it first to merge it, and then push it. This way, there is no hassle of switching branches back and forth.

    reply
    0
  • 大家讲道理

    大家讲道理2017-05-02 09:31:04

    git fetch ; git merge origin/他的分支

    reply
    0
  • PHPz

    PHPz2017-05-02 09:31:04

    In your branch

    git pull origin 他人分支

    reply
    0
  • 習慣沉默

    習慣沉默2017-05-02 09:31:04

    git fetch origin
    git merge origin/branch_name

    reply
    0
  • Cancelreply