gitlab Request to merge branch-A into develop (3 commits behind) should I worry?

后端 未结 4 1716
耶瑟儿~
耶瑟儿~ 2021-02-05 15:35

When creating a merge request in gitlab I often get a message: Request to merge branch-A into develop ([x] commits behind) what does gitlab want to tell me? should I worry or d

4条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-02-05 15:44

    After some time a merge request is open in a project it is normal that the version of the branch you are trying to merge into becomes outdated due to other people merging their own changes to it.

    Gitlab helps you by showing how much the version of the branch you updated is behind the remote branch.

    Being behind will not set any hindrance to the act of merging, but it is a common practice to rebase your commits on top of the branch your merging into. This will make your merge request updated by putting your commits chronologically after the ones that already are in that branch. That approach makes the work of the person responsible for the merge easier because the commiter himself has already resolved any conflicts that would have happened.

    To do a rebase following the scenario you proposed would be like this:

    # Add a remote named `upstream` pointing to the original repository
    git remote add upstream https://gitlab.example.com/example/your_project.git
    
    # Fetch the latest commmits from `upstream`
    git fetch upstream
    
    # Checkout our branch-A
    git checkout branch-A
    
    # Rebase our branch on top of the `upstream/develop` branch
    git rebase upstream/develop
    
    # If needed fix any conflicts that may have appeared and then `git rebase --continue`  
    
    # Push the changes to the branch of your merge request
    git push --force origin branch-A
    

    Note: The --force flag is necessary when you push because you are rewriting the commit history of origin/branch-A. From git's doc:

    [--force] can cause the remote repository to lose commits; use it with care.

提交回复
热议问题