glab-mr-create
Create GitLab merge requests from the command line
TLDR
Interactively create a merge request
Create a merge request, determining the title and description from the commit messages of the current branch
Create a draft merge request
Create a merge request specifying the target branch, title, and description
Start opening a merge request in the default web browser
SYNOPSIS
glab mr create [source-branch] [target-branch] [flags]
glab mr create --title "MR Title" [flags]
PARAMETERS
--title, -t
Set the title of the merge request. This is often a required field.
--description, -d
Provide a detailed description for the merge request. Can accept Markdown.
--assignee, -a
Assign one or more users to the merge request by username or ID.
--reviewer, -r
Request review from one or more users.
--label, -l
Attach one or more labels to the merge request, comma-separated.
--milestone, -m
Associate the merge request with a specific milestone.
--target-branch, -b
Specify the target branch for the merge request. Defaults to the project's default branch.
--source-branch, -s
Specify the source branch for the merge request. Defaults to the current Git branch.
--remove-source-branch
Automatically remove the source branch upon merge.
--squash-before-merge
Enable squash commits when merging the merge request.
--draft, --wip
Create the merge request as a draft (work in progress).
--allow-collaboration
Allow commits from members who can merge to the target branch.
--web
Open the newly created merge request in the default web browser.
--push, -p
Push current branch to remote before creating merge request.
--fill
Fill MR fields (title, description) from Git commit message, if not provided.
--yes, -y
Confirm creation without prompting for confirmation.
--output-format, -o
Set output format for the merge request details after creation.
--project
Specify the GitLab project (ID or path) to operate on.
DESCRIPTION
The glab mr create command provides a powerful and convenient way to initiate new merge requests directly from your command-line interface. It eliminates the need to navigate to the GitLab web UI, streamlining the development workflow, especially for developers who prefer staying in the terminal. This command intelligently infers the source and target branches if not explicitly specified, often defaulting to your current branch as the source and the project's default branch (e.g., 'main' or 'master') as the target. Users can specify a title, description, assignees, reviewers, labels, milestones, and more, all via command-line flags. It supports various options for pre-populating information, opening the merge request in a web browser, or even pushing changes to the remote repository before creation. This tool is an essential part of the glab CLI, enhancing productivity for GitLab users.
CAVEATS
Requires prior authentication with GitLab via glab auth login.
The command must be run within a Git repository that is linked to a GitLab project.
Permissions are inherited from your GitLab user account; you must have sufficient permissions to create merge requests in the target project.
If a title or description is not provided, glab might prompt you or try to infer from Git commit messages, depending on flags like --fill.
CONFIGURATION
glab respects environment variables like GITLAB_TOKEN and configuration files (e.g., ~/.config/glab-cli/config.yml) for project defaults, host, and authentication.
INTERACTIVE MODE
When required fields like title or description are not provided via flags, glab can enter an interactive mode, prompting the user for input. This behavior can be controlled by options like --yes or --fill.
HISTORY
glab is the official GitLab command-line tool, developed by GitLab Inc. and the open-source community. It was designed to bring the GitLab experience closer to the developer's terminal, similar to GitHub's gh CLI. The glab mr create command is a core functionality, present since early versions of glab, reflecting the importance of merge requests in the GitLab workflow. Its continuous development focuses on improving user experience, adding more options, and aligning with new GitLab features.