Home  >  Q&A  >  body text

git-gui - gitlab 如何跨分支merge?

现在我的同事A起了一个项目,分之为A,里面有一些说明和common.css等组件;
然后B同事新建分之B,
C同事在本地切换到B分之并创建C分之
然后B,C同事分别在各自的分支开发
开发完毕并且推送到远程,需要将项目内容合并到一个分支

问题1:能否将B分支合并到C分支或者C分支合并到B分支?

问题2:能都将B、C分支均合并到A分支?

问题3:merge to working tree和fast-forward merge有何区别?

另外,不希望rebase。
高洛峰高洛峰2727 days ago721

reply all(6)I'll reply

  • 某草草

    某草草2017-05-02 09:49:26

    Don’t you all have a public dev branch?
    Pull a development branch from dev. After development is completed, everyone will merge it into dev.
    Have conflicts and resolve conflicts.

    reply
    0
  • 高洛峰

    高洛峰2017-05-02 09:49:26

    First of all, native git supports the creation and merging of branches1, so all code version management tools based on git (such as gitlab/github) also support branch functions by default. (gitlab also has permission management functions )

    In addition, a major problem in the subject's project is as @52lidan said, There is no branch dev which leads to confusion in code version management (is the A, B or C branch the most important?) , so the advice to the subject is :

    1. The project must have the following branches

      • master: Code branch (protected) that can be officially released to the production environment2

      • dev: After development and preliminary testing, a working code branch is used to merge everyone’s work and fixed bugs (protected)

    2. Create a new branch for each task, and people follow the task instead of tasks following people. In other words, on the remote library, the task has only one branch, and everyone pulls it to the local. Everyone about The work of this task needs to be committed locally and then pushed to the task branch. (It is not recommended for more than three people to collaborate on a task, otherwise the task will be broken down into more branches)


    1. Creating and merging git branches ↩
    2. You can set the branch to protected in gitlab. Only people in the project who have obtained the owner/protected, 该分支只有项目中获得owner/master权限的人才能合并别人提交的merge request permission can merge the merge request submitted by others. ↩

    reply
    0
  • PHP中文网

    PHP中文网2017-05-02 09:49:26

    I don’t quite understand the meaning of the question. Merging itself is carried out between different branches. Why can’t it be merged across branches?

    reply
    0
  • 曾经蜡笔没有小新

    曾经蜡笔没有小新2017-05-02 09:49:26

    Even if the merge is on a first-come, first-served basis, if the local development is completed without pushing updates to the remote end, how can there be a merge situation? At least there should be a b on the remote end. If not, then merge it into a. But this is not good

    reply
    0
  • 仅有的幸福

    仅有的幸福2017-05-02 09:49:26

    Branches must have bifurcation points. The farther away from the bifurcation point, the greater the inconsistency in theory, and the more human intervention is needed to merge. There is no branch that cannot be merged without human intervention

    reply
    0
  • 迷茫

    迷茫2017-05-02 09:49:26

    Question 1: Yes
    Question 2: Yes
    Question 3: I don’t know

    reply
    0
  • Cancelreply