How to create a GitLab merge request from the command line
Short answer
Push your branch with git push -o merge_request.create -o merge_request.target=main and GitLab opens the merge request as it receives the push. More push options set the title, description, draft status, labels, assignees, milestone, squash, branch removal and auto-merge; none adds reviewers. With the GitLab CLI, glab mr create --fill --yes pushes the branch and fills in the title and description from your commits or branch name, and --reviewer requests a review. A plain git push also prints a link to create the merge request, when the project shows it.
You’ve committed the fix and you’re in the terminal. Switching to the browser to open a merge request is optional: GitLab can create it as it receives your push, and the GitLab CLI can do it with your commits as the description. Here are the ways to create a GitLab merge request from the command line in 2026.
With git push options
Add merge_request.create, and GitLab opens the merge request when the push arrives:
git switch -c fix-login
git commit -am "Fix the login redirect"
git push -o merge_request.create -o merge_request.target=main origin fix-login
More options fill in the rest:
| Push option | What it does |
|---|---|
merge_request.target=<branch> |
Sets the target branch. Required when you push from the default branch |
merge_request.target_project=<path> |
Targets another project, such as the upstream of your fork |
merge_request.title="<title>" |
Sets the title |
merge_request.description="<text>" |
Sets the description |
merge_request.draft |
Marks it as a draft |
merge_request.label="<label>" |
Adds a label, creating it if it doesn’t exist; repeat for more |
merge_request.assign="<user>" |
Assigns a user by username or ID; repeat for more on Premium and Ultimate |
merge_request.milestone="<milestone>" |
Sets the milestone |
merge_request.remove_source_branch |
Deletes the source branch when it merges |
merge_request.squash |
Squashes the commits when it merges (GitLab 17.2 and later) |
merge_request.auto_merge |
Sets it to auto-merge |
merge_request.unlabel and merge_request.unassign remove labels and assignees. merge_request.merge_when_pipeline_succeeds still exists but is deprecated in favour of auto_merge. There’s no option for reviewers.
Push options need Git 2.10 or later, or 2.13 or later if you push over HTTPS; -o is short for --push-option in all of them.
If you use the same options every time, save them as an alias. GitLab’s docs suggest one like this:
git config --global alias.mwps "push -o merge_request.create -o merge_request.target=main -o merge_request.auto_merge"
git mwps origin fix-login
With the GitLab CLI
glab mr create works from your current branch:
glab mr create --fill --yes
--fill uses the commit’s subject and body when there’s one commit; with several, it names the merge request after the branch and lists the commit subjects. It pushes the branch first, unless you add --push=false. Other flags you’ll want:
--target-branchor-bsets the target branch.--reviewer alexrequests a review, which push options can’t do;--assigneeassigns.--draft,--label,--milestoneand--auto-mergedo what they say.--remove-source-branchand--squash-before-mergeoverride the project defaults.--related-issue 42addsCloses #42to the description, titles the merge requestResolve "<issue title>"unless you pass--title, and always makes it a draft. Without--source-branch, it creates a new branch from the target branch instead of using your current one.--template bug_fixfills the description from.gitlab/merge_request_templates/.--webfinishes the merge request in your browser.
For example, a draft with a reviewer and a label:
glab mr create --fill --draft --reviewer alex --label backend --yes
The link a plain git push prints
Even without options, GitLab answers every push to a branch other than the default branch with a link:
remote: To create a merge request for fix-login, visit:
remote: https://gitlab.com/my-group/my-project/-/merge_requests/new?merge_request%5Bsource_branch%5D=fix-login
If the branch already has an open merge request, GitLab prints View merge request for fix-login: and that link instead. A Maintainer can turn the link off in Settings › Merge requests, under Show link to create or view a merge request when pushing from the command line. Pushes to the default branch never get one.
With the API
curl --request POST \
--header "PRIVATE-TOKEN: <your_access_token>" \
--data "source_branch=fix-login" \
--data "target_branch=main" \
--data-urlencode "title=Fix the login redirect" \
--url "https://gitlab.example.com/api/v4/projects/5/merge_requests"
source_branch, target_branch and title are required. The same call takes description, assignee_ids, reviewer_ids, labels, squash and remove_source_branch.
After you push
Once the merge request is open and the reviewers are requested, each of them gets a to-do item. MergeBell turns that to-do into a push on their phone: free, checked every five minutes, or every minute on Pro. If you pushed from the default branch by mistake and GitLab refused it, see why GitLab says you’re not allowed to push to a protected branch.
Frequently asked questions
How do I create a merge request from the command line in GitLab?
Push your branch with git push -o merge_request.create -o merge_request.target=main origin my-branch, and GitLab creates the merge request when it receives the push. Or, with the GitLab CLI installed, run glab mr create --fill --yes from the branch.
Can I add reviewers with git push options?
No. Push options can set assignees, labels, a milestone, the title, the description and draft status, but there is no reviewer option. Use glab mr create --reviewer, or request the review in GitLab after the push.
Do I need merge_request.target?
Only sometimes. When you push from the default branch, merge_request.create needs merge_request.target to know where the merge request goes. Without it, GitLab uses the default branch of the default target project, which for a fork is usually the upstream, so set it whenever you want a different target.
Which Git version do push options need?
Git 2.10 or later, or 2.13 or later if you push over HTTPS. -o and --push-option are the same option.
Why didn't git push print a merge request link?
The project may have turned off Show link to create or view a merge request when pushing from the command line, in Settings › Merge requests. GitLab also prints no link for a push to the default branch, or when merge requests are turned off.
Sources
- GitLab docs — Push options for merge requests
- GitLab docs — Create a merge request
- GitLab CLI docs — glab mr create
- GitLab docs — Merge requests API: create a merge request
- Git documentation — git-push --push-option
Checked against these pages on 25 October 2026. GitLab changes quickly — if something here no longer matches, tell us and we will fix it.
Do this from your phone with MergeBell
Free for the whole review loop: the To-Do inbox, diffs and line comments, approve and merge, pipelines with retry, and push alerts for your To-Dos. Works with gitlab.com and self-managed GitLab 16.0+.
Get MergeBell for AndroidiPhone: email me at launch
On Google Play for Android 12 or later. The iPhone app is coming soon to the App Store. An independent app, not affiliated with GitLab Inc.