How to locally test a pull request from gitlab?

In order to review/test a github pull request, one could use this command:

git fetch remote pull/ID/head:branch_to_use_locally

Here, remote is a project on github. More details in github FAQ.

What is the corresponding command when one uses gitlab?

  • Git flow with Bitbucket pull requests
  • Pull requests overriding earlier commits
  • Send a pull request for a specific folder?
  • Cloning a pull request
  • multiple pull requests from the same branch
  • Is it possible to receive notifications when a comment is added to a TFS Git pull request?
  • Determining why github says “Closed with unmerged commits”
  • Why doesn't the Travis git ref match my pull request sometimes?
  • 2 Solutions collect form web for “How to locally test a pull request from gitlab?”

    It is quite similar. The little differences exist because in GitLab merge requests are used instead of pull requests from GitHub. This consists in creating a branch away from master and merging into it later.

    To test a Merge Request all you need to do is to fetch and checkout the branch sent for merge:

    git fetch <repo> <branch>
    git checkout -b <branch>

    Also there is a button in every merge request with the instructions to checkout the diffs locally:
    enter image description here

    First pull merge request to a new branch

    git fetch REMOTE merge-requests/MERGE_REQUEST_ID/head:BRANCH_NAME

    Real example would be like: git fetch origin merge-requests/1/head:add_some_feature

    Then check it out

    git checkout BRANCH_NAME

    In above example would be like: git checkout add_some_feature

    Now check the new branch.

    Important point: BRANCH_NAME is the source branch of merge request. it isn’t the target branch.

    Git Baby is a git and github fan, let's start git clone.