LinuxCommandLibrary

git-mr

Create merge requests from the command line

TLDR

Check out a specific merge request

$ git mr [mr_number]
copy

Check out a merge request from a specific remote
$ git mr [mr_number] [remote]
copy

Checkout a merge request from its URL
$ git mr [url]
copy

Clean up old merge request branches
$ git mr clean
copy

SYNOPSIS

git mr command [args]

git mr list [remote]
git mr checkout MR_ID
git mr create [options]
git mr show MR_ID
git mr open MR_ID
git mr delete MR_ID
git mr browse MR_ID
git mr help

PARAMETERS

list [remote]
    Lists open merge requests. If remote is specified, it lists MRs for that specific remote.

checkout MR_ID
    Checks out the source branch of the specified merge request locally, making it ready for review or further development.

create
    Initiates the creation of a new merge request. Various options are available to customize its properties.

create -t title, --title title
    Sets the title for the new merge request. Defaults to the first commit message if not provided.

create -d description, --description description
    Sets the detailed description for the new merge request.

create -s source_branch, --source source_branch
    Specifies the source branch for the merge request. Defaults to your current local branch.

create -T target_branch, --target target_branch
    Specifies the target branch for the merge request. Defaults to the default branch of the remote.

create -M, --squash
    Enables the squash commits option for the new merge request, allowing commits to be squashed upon merging.

create -w, --wip
    Marks the new merge request as a Work-in-Progress (Draft), preventing accidental merges.

create -a, --assignee
    Assigns the new merge request to yourself (the current authenticated user).

create -i issue_id, --issue issue_id
    Associates the new merge request with a specific issue by its ID.

create -r reviewer, --reviewer reviewer
    Assigns a reviewer to the new merge request by their GitLab username.

create -c CI_CONFIG, --ci-config CI_CONFIG
    Specifies a custom CI configuration path for the new merge request.

create -f file, --file file
    Reads the title and description for the new merge request from the specified file.

show MR_ID
    Displays detailed information about a specific merge request, including its status, source, and target branches.

open MR_ID
    Opens the specified merge request in your default web browser, navigating directly to its GitLab page.

delete MR_ID
    Deletes a specific merge request. Use with caution as this action is typically irreversible.

browse MR_ID
    An alias for the open subcommand, providing an alternative way to open the MR in a browser.

help
    Displays general help information for git-mr or detailed help for a specific subcommand.

DESCRIPTION

git-mr is a powerful Git subcommand designed to streamline interaction with GitLab Merge Requests directly from the command line. It eliminates the need to navigate the GitLab web interface for common merge request operations. Users can effortlessly list open merge requests, check out a merge request's branch for local review, create new merge requests, or open an existing merge request in the browser. This tool integrates seamlessly into existing Git workflows, making development faster and more efficient, especially for teams heavily reliant on GitLab for code collaboration and review. It leverages GitLab's API to fetch and submit merge request information, providing a comprehensive command-line interface for managing the merge request lifecycle.

CAVEATS

This command is not a standard Git utility and requires separate installation, typically as a Python script. It relies on a configured GitLab API token (personal access token) for authentication and interaction with GitLab instances. Functionality is specific to GitLab Merge Requests and does not directly support GitHub Pull Requests or other Git hosting platforms. Ensure proper configuration of your GitLab remote URL and API token in your Git repository or environment variables for the tool to function correctly.

INSTALLATION AND CONFIGURATION

To use git-mr, you typically need to install it, often via pip if using the Python version (e.g.,
pip install git-mr).

Configuration involves setting up your GitLab API token and the GitLab instance URL. This can be done via Git configuration (e.g.,
git config --global gitlab.token your_token
and
git config --global gitlab.url https://gitlab.com)
or through environment variables. Ensure the remote associated with your GitLab project is correctly configured in your Git repository.

HISTORY

The git-mr command, particularly the widely used Python-based implementation by Andrew Dunn, originated to bridge a gap in command-line interactions with GitLab's Merge Request system. Inspired by similar tools for GitHub, it aimed to provide developers with a native Git subcommand for common MR workflows, thereby reducing reliance on the web interface. Since its inception, it has been maintained as an open-source project, with contributions from the community enhancing its features and robustness over time, making it a popular choice for GitLab users who prefer terminal-centric development.

SEE ALSO

Copied to clipboard