- Enabling commit edits from upstream members
- Pushing to the fork as the upstream member
- Troubleshooting
Allow collaboration on merge requests across forks
Introduced in GitLab 10.6.
When a user opens a merge request from a fork, they are given the option to allow upstream members to collaborate with them on the source branch. This allows the members of the upstream project to make small fixes or rebase branches before merging, reducing the back and forth of accepting external contributions.
This feature is available for merge requests across forked projects that are publicly accessible.
When enabled for a merge request, members with merge access to the target branch of the project is granted write permissions to the source branch of the merge request.
Enabling commit edits from upstream members
In GitLab 13.7 and later, this setting is enabled by default. It can be changed by users with the Developer role for the source project. After it’s enabled, upstream members can retry the pipelines and jobs of the merge request:
- While creating or editing a merge request, scroll to Contribution and then select the Allow commits from members who can merge to the target branch. checkbox.
- Finish creating your merge request.
After you create the merge request, the merge request widget displays a message: Members who can merge are allowed to add commits.
Pushing to the fork as the upstream member
If the creator of the merge request has enabled contributions from upstream members, you can push directly to the branch of the forked repository.
Assuming that:
- The forked project URL is
git@gitlab.com:thedude/awesome-project.git
. - The branch of the merge request is
update-docs
.
To find and work with the changes from the fork:
- Open the merge request page, and select the Overview tab.
- Scroll to the merge request widget, and select Check out branch:
-
In the modal window, select (Copy) for step 1 to copy the
git fetch
andgit checkout
instructions to your clipboard. Paste the commands (which look like this example) into your terminal:git fetch git@gitlab.com:thedude/awesome-project.git update-docs git checkout -b thedude-awesome-project-update-docs FETCH_HEAD
These commands fetch the branch from the forked project, and create a local branch based off the fetched branch.
- Make your changes to the local copy of the branch, and then commit them.
-
In your terminal, push your local changes back up to the forked project. This command pushes the local branch
thedude-awesome-project-update-docs
to theupdate-docs
branch of thegit@gitlab.com:thedude/awesome-project.git
repository:git push git@gitlab.com:thedude/awesome-project.git thedude-awesome-project-update-docs:update-docs
Note the colon (
:
) between the two branches.
Troubleshooting
Pipeline status unavailable from MR page of forked project
When a user forks a project, the permissions of the forked copy are not copied from the original project. The creator of the fork must grant permissions to the forked copy before members in the upstream project can view or merge the changes in the merge request.
To see the pipeline status from the merge request page of a forked project going back to the original project:
- Create a group containing all the upstream members.
- Go to the Project information > Members page in the forked project and invite the newly-created group to the forked project.