GLab is an open source GitLab CLI tool bringing GitLab to your terminal next to where you are already working with git
and your code without switching between windows and browser tabs. Work with issues, merge requests, watch running pipelines directly from your CLI among other features.
glab
is available for repositories hosted on GitLab.com and self-managed GitLab instances. glab
supports multiple authenticated GitLab instances and automatically detects the authenticated hostname from the remotes available in the working Git directory.
- Table of contents
- Requirements
- Usage
- Demo
- Documentation
- Installation
- Authentication
- Configuration
- Environment variables
- Issues
- Contributing
- Inspiration
glab
officially supports GitLab versions 16.0 and later. Certain commands might require
more recent versions. While many commands might work properly in GitLab versions
15.x and earlier, no support is provided for these versions.
To get started with glab
:
- Follow the installation instructions appropriate for your operating system.
- Authenticate into your instance of GitLab.
- Optional. Configure
glab
further to meet your needs:- 1Password users can configure it to authenticate to
glab
. - Set any needed global, per-project, or per-host configuration.
- Set any needed environment variables.
- 1Password users can configure it to authenticate to
You're ready!
Run glab --help
to view a list of core commands in your terminal.
glab alias
glab api
glab auth
glab changelog
glab check-update
glab ci
glab cluster
glab completion
glab config
glab duo
glab incident
glab issue
glab label
glab mr
glab release
glab repo
glab schedule
glab snippet
glab ssh-key
glab stack
glab user
glab variable
Commands follow this pattern:
glab <command> <subcommand> [flags]
Many core commands also have sub-commands. Some examples:
- List merge requests assigned to you:
glab mr list --assignee=@me
- List review requests for you:
glab mr list --reviewer=@me
- Approve a merge request:
glab mr approve 235
- Create an issue, and add milestone, title, and label:
glab issue create -m release-2.0.0 -t "My title here" --label important
The GitLab CLI also provides support for GitLab Duo AI/ML powered features. These include:
Use glab duo ask
to ask questions about git
commands. It can help you remember a
command you forgot, or provide suggestions on how to run commands to perform other tasks.
Read the documentation for usage instructions or check out glab help
.
Download a binary suitable for your OS at the releases page. Other installation methods depend on your operating system.
Homebrew is the officially supported package manager for macOS, Linux, and Windows (through Windows Subsystem for Linux)
- Homebrew
- Install with:
brew install glab
- Update with:
brew upgrade glab
- Install with:
Other options to install the GitLab CLI that may not be officially supported or are maintained by the community are also available.
If a supported binary for your OS is not found at the releases page, you can build from source:
make
- Go 1.22+
To build from source:
- Run the command
go version
to verify that Go version 1.22 or later is installed. Ifgo
is not installed, follow instructions on the Go website. - Run the
go install gitlab.com/gitlab-org/cli/cmd/glab@main
to installglab
cmd in$GOPATH/bin
. - The sources of
glab
will be in$GOPATH/src/gitlab.com/gitlab-org/cli
. - If you do not have
$GOPATH/bin
or$GOBIN
in your$PATH
, runexport PATH=$PWD/bin:$PATH
to update your PATH with the newly compiled project. - Run
glab version
to confirm that it worked.
To authenticate your installation of glab
with an OAuth application connected to GitLab.com:
- Start interactive setup with
glab auth login
. - For the GitLab instance you want to sign in to, select GitLab.com.
- For the login method, select Web. This selection launches your web browser to request authorization for the GitLab CLI to use your GitLab.com account.
- Select Authorize.
- Complete the authentication process in your terminal, selecting the appropriate options for your needs.
Prerequisites:
- You've created an OAuth application at the user, group, or instance level, and you have its application ID. For instructions, see how to configure GitLab as an OAuth 2.0 authentication identity provider in the GitLab documentation.
- Your OAuth application is configured with these parameters:
- Redirect URI is
http://localhost:7171/auth/redirect
. - Confidential is not selected.
- Scopes are
openid
,profile
,read_user
,write_repository
, andapi
.
- Redirect URI is
To authenticate your installation of glab
with an OAuth application connected
to your self-managed instance:
- Store the application ID with
glab config set client_id <CLIENT_ID> --host <HOSTNAME>
. For<CLIENT_ID>
, provide your application ID. - Start interactive setup with
glab auth login --hostname <HOSTNAME>
. - For the login method, select Web. This selection launches your web browser to request authorization for the GitLab CLI to use your self-managed account.
- Select Authorize.
- Complete the authentication process in your terminal, selecting the appropriate options for your needs.
To authenticate your installation of glab
with a personal access token:
- Get a GitLab personal access token with at least the
api
andwrite_repository
scopes. Use the method appropriate for your instance:- For GitLab.com, create one at the personal access tokens page.
- For self-managed instances, visit
https://gitlab.example.com/-/user_settings/personal_access_tokens?scopes=api,write_repository
, modifyinggitlab.example.com
to match the domain name of your instance.
- Start interactive setup:
glab auth login
- Authenticate with the method appropriate for your GitLab instance:
- For GitLab SaaS, authenticate against
gitlab.com
by reading the token from a file:glab auth login --stdin < myaccesstoken.txt
- For self-managed instances, authenticate by reading from a file:
glab auth login --hostname gitlab.example.com --stdin < myaccesstoken.txt
. This will allow you to perform authenticatedglab
commands against a self-managed instance when you are in a Git repository with a remote matching your self-managed instance's host. Alternatively setGITLAB_HOST
to direct your command to your self-managed instance. - Authenticate with token and hostname:
glab auth login --hostname gitlab.example.org --token xxxxx
Not recommended for shared environments. - Credentials are stored in the global configuration file.
- For GitLab SaaS, authenticate against
To authenticate your installation of glab
with a CI job token, the glab
command must be run in a GitLab CI job.
The token is automatically provided by the GitLab Runner via the CI_JOB_TOKEN
environment variable.
Example:
glab auth login --job-token $CI_JOB_TOKEN --hostname $CI_SERVER_HOST --api-protocol $CI_SERVER_PROTOCOL
GITLAB_HOST=$CI_SERVER_URL glab release list -R $CI_PROJECT_PATH
Endpoints allowing the use of the CI job token are listed in the GitLab documentation.
By default, glab
follows the
XDG Base Directory Spec.
Configure it globally, locally, or per host:
- Globally: run
glab config set --global editor vim
.- The global configuration file is available at
~/.config/glab-cli/config.yml
. - To override this location, set the
GLAB_CONFIG_DIR
environment variable.
- The global configuration file is available at
- The current repository: run
glab config set editor vim
in any folder in a Git repository.- The local configuration file is available at
.git/glab-cli/config.yml
in the current working Git directory.
- The local configuration file is available at
- Per host: run
glab config set editor vim --host gitlab.example.org
, changing the--host
parameter to meet your needs.- Per-host configuration info is always stored in the global configuration file, with or without the
global
flag.
- Per-host configuration info is always stored in the global configuration file, with or without the
When outside a Git repository, glab
uses gitlab.com
by default. For glab
to default
to your self-managed instance when you are not in a Git repository, change the host
configuration settings. Use this command, changing gitlab.example.com
to the domain name
of your instance:
glab config set -g host gitlab.example.com
Setting this configuration enables you to perform commands outside a Git repository while using your self-managed instance. For example:
glab repo clone group/project
glab issue list -R group/project
If you don't set a default domain name, you can declare one for the current command with
the GITLAB_HOST
environment variable, like this:
GITLAB_HOST=gitlab.example.com glab repo clone group/project
GITLAB_HOST=gitlab.example.com glab issue list -R group/project
When inside a Git repository glab
will use that repository's GitLab host by default. For example glab issue list
will list all issues of the current directory's Git repository.
The GitLab CLI can be configured to support self-managed instances using self-signed certificate authorities by making either of the following changes:
You can disable TLS verification with:
glab config set skip_tls_verify true --host gitlab.example.com
Or add the path to the self signed CA:
glab config set ca_cert /path/to/server.pem --host gitlab.example.com
GITLAB_TOKEN
: an authentication token for API requests. Setting this avoids being prompted to authenticate and overrides any previously stored credentials. Can be set in the config withglab config set token xxxxxx
GITLAB_URI
orGITLAB_HOST
: specify the URL of the GitLab server if self-managed (eg:https://gitlab.example.com
). Default ishttps://gitlab.com
.GITLAB_API_HOST
: specify the host where the API endpoint is found. Useful when there are separate (sub)domains or hosts for Git and the API endpoint: defaults to the hostname found in the Git URLGITLAB_CLIENT_ID
: a custom Client-ID generated by the GitLab OAuth 2.0 application. Defaults to the Client-ID for GitLab.com.GITLAB_REPO
: Default GitLab repository used for commands accepting the--repo
option. Only used if no--repo
option is given.GITLAB_GROUP
: Default GitLab group used for listing merge requests, issues and variables. Only used if no--group
option is given.REMOTE_ALIAS
orGIT_REMOTE_URL_VAR
:git remote
variable or alias that contains the GitLab URL.GLAB_CONFIG_DIR
: Directory where glab's global configuration file is located. Defaults to~/.config/glab-cli/
if not set. Can be set in the config withglab config set remote_alias origin
VISUAL
,EDITOR
(in order of precedence): the editor tool to use for authoring text. Can be set in the config withglab config set editor vim
BROWSER
: the web browser to use for opening links. Can be set in the configuration withglab config set browser mybrowser
GLAMOUR_STYLE
: environment variable to set your desired Markdown renderer style Available options are (dark
|light
|notty
) or set a custom styleNO_COLOR
: set to any value to avoid printing ANSI escape sequences for color output.FORCE_HYPERLINKS
: set to1
to force hyperlinks to be output, even when not outputting to a TTYDEBUG
: set to1
ortrue
to output additional information for each command
GLab uses tokens in this order:
- Environment variable (
GITLAB_TOKEN
). - Configuration file (
$HOME/.config/glab-cli/config.yml
).
When the DEBUG
environment variable is set to 1
or true
, glab
outputs more logging information, including:
- Underlying Git commands.
- Expanded aliases.
- DNS error details.
If you have an issue: report it on the issue tracker
Feel like contributing? That's awesome! We have a contributing guide and Code of conduct to help guide you.
This project follows the SemVer specification.
- If deleting a command, changing how it behaves, or adding a new required flag, the release must use a new
MAJOR
revision. - If adding a new command or optional flag, the release must use a new
MINOR
revision. - If fixing a bug, the release must use a new
PATCH
revision.
We do our best to introduce breaking changes only when releasing a new MAJOR
version.
Unfortunately, there are situations where this is not possible, and we may introduce
a breaking change in a MINOR
or PATCH
version. Some of situations where we may do so:
- If a security issue is discovered, and the solution requires a breaking change, we may introduce such a change to resolve the issue and protect our users.
- If a feature was not working as intended, and the bug fix requires a breaking change, the bug fix may be introduced to ensure the functionality works as intended.
- When feature behavior is overwhelmingly confusing due to a vague specification on how it should work. In such cases, we may refine the specification to remove the ambiguity, and introduce a breaking change that aligns with the refined specification. For an example of this, see merge request 1382.
- Experimental features are not guaranteed to be stable, and can be modified or removed without a breaking change.
Breaking changes are a last resort, and we try our best to only introduce them when absolutely necessary.
The GitLab CLI was adopted from Clement Sam in 2022 to serve as the official CLI of GitLab. Over the years the project has been inspired by both the GitHub CLI and Zaq? Wiedmann's lab.
Lab has served as the foundation for many of the GitLab CI/CD commands including ci view
and ci trace
.