Search code examples
gitlabgitlab-apimerge-request

How to create a merge request for forked repo into main repo via Gitlab REST Api


What I try to accomplish to merge changes of forked repo into main repo. Both repo’s master branch are protected. I can accomplish it via Gitlab web pages. But unfortunately, Gitlab rest api for merge request does not have source_project_id attribute.

Is there any way to create merge request via command line for forked repo into main repo ?


Solution

  • When using the API, you would use the MR endpoint for the source project -- the fork that you created.

    Suppose the "main" project is owner/main-project and your fork is user/main-project-fork

    You would use the MR API endpoint (/projects/:id/merge_requests) using the id (or url-encoded path) of user/main-project-fork. Then you would provide the target_project_id parameter using the ID of the owner/main-project project.