In order to review/test a GitLab pull request, one could use this command:
git fetch remote pull/ID/head:branch_to_use_locally
Here, remote
is a project on GitLab. More details in GitLab FAQ.
What is the corresponding command when one uses GitLab?
To check out a pull request locally, use the gh pr checkout subcommand. Replace pull-request with the number, URL, or head branch of the pull request.
If you want to bring that specific COMMIT_ID to your local branch, you may either use git-cherry-pick to bring only that commit over, or git-merge to bring all changes up to that commit to your local branch.
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:
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's not the target branch.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With