LinuxCommandLibrary

glab-mr

Create, view, and manage GitLab merge requests

TLDR

Create a merge request

$ glab mr create
copy

Check out a specific merge request locally
$ glab mr checkout [mr_number]
copy

View the changes made in the merge request
$ glab mr diff
copy

Approve the merge request for the current branch
$ glab mr approve
copy

Merge the merge request associated with the current branch interactively
$ glab mr merge
copy

Edit a merge request interactively
$ glab mr update
copy

Edit the target branch of a merge request
$ glab mr update --target-branch [branch_name]
copy

SYNOPSIS

glab mr <command> [flags]

Common commands include:
glab mr create [branch] [flags]
glab mr list [flags]
glab mr view <id> [flags]
glab mr merge <id> [flags]
glab mr close <id> [flags]

PARAMETERS

<command>
    The specific operation to perform on a merge request. Common commands include create, list, view, merge, close, approve, diff, rebase, and checkout.

create [branch]
    Creates a new merge request. If branch is not specified, it typically defaults to the current branch.

list
    Lists merge requests based on various filters (e.g., state, assignee, author).

view <id>
    Views detailed information about a specific merge request identified by its <id> (IID or URL).

merge <id>
    Merges a specified merge request.

close <id>
    Closes a specified merge request.

approve <id>
    Approves a specified merge request.

diff <id>
    Displays the diff of a specified merge request.

rebase <id>
    Rebases a specified merge request onto its target branch.

checkout <id>
    Checks out the source branch of a specified merge request locally.

--help
    Shows help for glab mr or any of its subcommands.

--repo <repository>
    Specify the GitLab repository (e.g., owner/repo_name) to operate on, overriding the default detected from the current Git directory.

--hostname <hostname>
    Specify the GitLab instance hostname to use, overriding the default or configured hostname.

DESCRIPTION

glab mr is a powerful subcommand of glab, the official GitLab Command Line Interface. It provides a comprehensive set of functionalities to interact with GitLab Merge Requests directly from your terminal. Users can create, list, view, merge, close, approve, and perform various other operations on merge requests without needing to access the GitLab web interface.

This command-line tool streamlines development workflows, especially for developers who prefer working in a terminal environment. It leverages the GitLab API to communicate with your GitLab instance, requiring proper authentication, typically via a Personal Access Token or OAuth.

CAVEATS

Using glab mr requires a properly configured glab CLI installation. This includes setting up authentication, typically via a GitLab Personal Access Token with appropriate scopes, or OAuth.

Commands rely on network connectivity to the GitLab instance. Permissions on the GitLab project are respected, so users can only perform actions they are authorized for in the web interface.

AUTHENTICATION

glab mr commands authenticate using a GitLab Personal Access Token or OAuth. This token can be configured via glab auth login, an environment variable (e.g., GITLAB_TOKEN), or in the glab configuration file (typically ~/.config/glab-cli/config.yml).

DEFAULT REPOSITORY

By default, glab mr operates on the GitLab repository associated with the current Git working directory's remote. If no remote points to a GitLab instance, or if operating outside a Git repository, the --repo flag must be used to specify the target project.

HISTORY

glab was developed to provide a native command-line interface for GitLab, similar to how gh serves GitHub. The glab mr subcommand is a core component, offering comprehensive merge request management directly from the terminal. It has been continuously developed and maintained by the GitLab community and open-source contributors, evolving with new GitLab features and user demands.

SEE ALSO

glab(1), git(1), gh(1)

Copied to clipboard