LinuxCommandLibrary

glab

Interact with GitLab from the command line

TLDR

Clone a GitLab repository locally

$ glab repo clone [owner]/[repository]
copy

Create a new issue
$ glab issue create
copy

View and filter the open issues of the current repository
$ glab issue list
copy

View an issue in the default browser
$ glab issue view [[-w|--web]] [issue_number]
copy

Create a merge request
$ glab mr create
copy

View a pull request in the default web browser
$ glab mr view [[-w|--web]] [pr_number]
copy

Check out a specific pull request locally
$ glab mr checkout [pr_number]
copy

SYNOPSIS

glab <command> [<flags>] [<arguments>...]
glab <group> <subcommand> [<flags>] [<arguments>...]

PARAMETERS

-h, --help
    Show help for the current command or subcommand.

-v, --version
    Show the glab version information.

-R, --repo <path>|<owner>/<repo>
    Specify a GitLab repository to operate on (e.g., gitlab-org/glab or /home/user/my-repo).

--gitlab-hostname <hostname>
    Specify the GitLab hostname to interact with (e.g., gitlab.com or my-gitlab.com).

--token <token>
    Provide a GitLab personal access token for authentication, overriding configured credentials.

--confirm
    Confirm any prompts without user interaction, useful for scripting or automation.

--no-prompt
    Disable interactive prompts, similar to --confirm.

--output <format>
    Format the command's output (e.g., json, yaml, text, csv).

--color <when>
    Control color output (options include always, auto, never).

--verbose
    Enable verbose output for debugging purposes, showing additional details about operations.

DESCRIPTION

glab is the official open-source command-line tool for interacting with GitLab. It brings a rich set of GitLab's features directly to your terminal, enabling developers and DevOps engineers to streamline their workflows without leaving the command line. With glab, users can effortlessly manage common GitLab operations such as listing, creating, and updating issues and merge requests, viewing and interacting with CI/CD pipelines, browsing repositories, and much more. It's designed for user-friendliness, providing a consistent and intuitive interface similar to how gh (GitHub CLI) interacts with GitHub.

glab supports both GitLab.com and self-hosted GitLab instances, making it a versatile tool for any GitLab user. It significantly enhances productivity by allowing for scripting and automation of repetitive tasks, integrating seamlessly into existing development environments and CI/CD pipelines. Its active development ensures continuous alignment with new GitLab features and community needs.

CAVEATS

glab requires an internet connection to communicate with GitLab instances. Authentication via a GitLab Personal Access Token is typically necessary for most operations, especially those involving private repositories or sensitive actions. While comprehensive, glab might not expose every single nuance of the GitLab web interface or API directly through a command, though it covers the most common workflows. As an actively developed tool, commands and options may evolve or be added in future versions.

AUTHENTICATION

The primary method to authenticate glab is by running glab auth login. This command guides the user through the process of obtaining and storing a GitLab Personal Access Token, which glab uses for all authenticated operations. It supports various authentication methods, including web browser flows and token pasting.

CONFIGURATION

glab allows users to configure global settings and preferences using the glab config command. This includes setting the default GitLab hostname, preferred text editor for interactive prompts, and other behaviors. Configuration files are typically stored in the user's home directory, allowing for persistent settings across sessions.

EXTENSIBILITY

glab supports custom extensions, allowing users to create their own commands or integrate external scripts to extend its functionality. This extensibility provides a powerful way to tailor glab to specific workflows or integrate it with other tools and services, fostering a highly customizable command-line experience.

HISTORY

glab originated as an independent community project, aiming to fulfill the need for a robust command-line interface for GitLab, mirroring the success of tools like gh for GitHub. Its utility and growing popularity led to its eventual adoption as the official GitLab CLI by GitLab Inc. This formal integration has ensured consistent development, better alignment with GitLab's product roadmap, and enhanced support for users. The project remains open-source, benefiting from continued community contributions and rapid feature iterations, constantly evolving to meet the demands of GitLab users worldwide.

SEE ALSO

git(1), gh(1), curl(1), ssh(1)

Copied to clipboard