A GitLab CLI tool bringing GitLab to your command line
Go to file
Jean-Philippe Baconnais 2677df1df4 [Suggestion] - 🚀 Init gitpod configuration file 2022-10-17 17:53:10 +00:00
.github docs: remove github references 2022-09-13 14:30:16 -05:00
.gitlab docs: contribution and security updates for GitLab 2022-09-19 18:19:26 +00:00
api Adding security MRs to setup auto mirroring 2022-10-13 05:01:51 +00:00
cmd chore: update module path 2022-09-19 20:23:45 +00:00
commands Merge branch 'feat/1056/path-display-proj-search' into 'main' 2022-10-06 21:51:20 +00:00
docs Merge branch 'stingrayza-filter-spelling' into 'main' 2022-10-06 20:17:13 +00:00
internal chore: fix misspelled words from goreportcard 2022-10-05 15:50:43 -05:00
pkg chore: fix misspelled words from goreportcard 2022-10-05 15:50:43 -05:00
scripts Fix aarch64 install error 2022-09-15 02:13:50 +00:00
snap Revert "Add config-git descriptive interface reference " 2021-02-03 15:26:43 +00:00
test chore: update module path 2022-09-19 20:23:45 +00:00
.gitignore Adding a very simple projectionist config 2022-09-12 10:26:51 -05:00
.gitlab-ci.yml test: add coverage to gitlab ci 2022-10-04 19:30:12 +00:00
.gitpod.yml [Suggestion] - 🚀 Init gitpod configuration file 2022-10-17 17:53:10 +00:00
.golangci.yml Migrate lint.yml to Gitlab CI 2022-04-21 15:10:13 +00:00
.goreleaser.yml chore: add macOS arm64 build to goreleaser 2022-08-10 19:45:39 +00:00
.projections.json.example Adding a very simple projectionist config 2022-09-12 10:26:51 -05:00
CODE_OF_CONDUCT.md docs: contribution and security updates for GitLab 2022-09-19 18:19:26 +00:00
CONTRIBUTING.md Add info on what GITLAB_TOKEN should be 2022-10-11 14:46:02 +00:00
Dockerfile build/goreleaser: docker images 2021-06-08 02:55:18 +00:00
LICENSE Transition copyright/license to GitLab 2022-04-04 12:33:40 +00:00
Makefile chore: update module path 2022-09-19 20:23:45 +00:00
README.md [Suggestion] - 🚀 Init gitpod configuration file 2022-10-17 17:53:10 +00:00
SECURITY.md docs: contribution and security updates for GitLab 2022-09-19 18:19:26 +00:00
go.mod build(deps): upgrade github.com/xanzy/go-gitlab to v0.73.1 2022-10-04 19:29:02 +00:00
go.sum build(deps): upgrade github.com/xanzy/go-gitlab to v0.73.1 2022-10-04 19:29:02 +00:00

README.md

GLab

GLab

Go Report Card Coverage Mentioned in Awesome Go Gitpod Ready-to-Code

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.

command example

Table of contents

Usage

glab <command> <subcommand> [flags]

Demo

asciicast

Documentation

Read the documentation for usage instructions.

Installation

Download a binary suitable for your OS at the releases page.

Quick install

Supported Platforms: Linux and macOS

Homebrew quick install

brew install glab

Updating (Homebrew):

brew upgrade glab

Alternatively, you can install glab by shell script:

curl -sL https://j.mp/glab-cli | sudo sh

or

curl -s https://gitlab.com/gitlab-org/cli/-/raw/main/scripts/install.sh | sudo sh

Installs into usr/bin

NOTE: Take care when running scripts in this fashion. Consider peeking at the install script itself and verify that it works as intended.

Windows

Available for download via WinGet, scoop, or downloadable EXE installer file.

WinGet

winget install glab.glab

Updating (WinGet):

winget install glab.glab

Scoop

scoop install glab

Updating (Scoop):

scoop update glab

EXE Installer

EXE installers are available for download on the releases page.

Linux

Prebuilt binaries available at the releases page.

Linuxbrew (Homebrew)

brew install glab

Updating (Homebrew):

brew upgrade glab

Snapcraft

Get it from the Snap Store

  1. Make sure you have snap installed on your Linux distribution.
  2. sudo snap install --edge glab
  3. sudo snap connect glab:ssh-keys to grant ssh access

Arch Linux

glab is available through the community/glab package or download and install an archive from the releases page. Arch Linux also supports snap.

pacman -S glab

KISS Linux

WARNING: It seems that KISS Linux may no longer be actively maintained, so links to its web domain have been removed from this README.

glab is available on the KISS Linux Community Repository as gitlab-glab. If you already have the community repository configured in your KISS_PATH you can install glab through your terminal.

kiss b gitlab-glab && kiss i gitlab-glab

Alpine Linux

glab is available on the Alpine Community Repository as glab.

Install

We use --no-cache so an apk update is not required.

apk add --no-cache glab
Install a pinned version from edge

To ensure that by default edge is used to get the latest updates. We need the edge repository in /etc/apk/repositories.

Afterwards you can install it with apk add --no-cache glab@edge

We use --no-cache so an apk update is not required.

echo "@edge http://dl-cdn.alpinelinux.org/alpine/edge/community" >> /etc/apk/repositories
apk add --no-cache glab@edge
Alpine Linux Docker-way

Use edge directly

FROM alpine:3.13
RUN apk add --no-cache glab

Fetching latest glab version from edge

FROM alpine:3.13
RUN echo "@edge http://dl-cdn.alpinelinux.org/alpine/edge/community" >> /etc/apk/repositories
RUN apk add --no-cache glab@edge

Nix/NixOS

Nix (NixOS) users can install from nixpkgs:

nix-env -iA nixos.glab

MPR (Debian/Ubuntu)

glab is available inside the makedeb package repository. To install, run the following:

git clone 'https://mpr.makedeb.org/glab'
cd glab/
makedeb -si
Prebuilt-MPR

The above method downloads glab from source and builds it before packaging it into a .deb package. If you don't want to compile or just want a prebuilt package, you can also install glab from the Prebuilt-MPR.

First set up the Prebuilt-MPR on your system, and then run the following:

sudo apt install glab

Spack

spack install glab

Updating (Spack):

spack uninstall glab && spack install glab

macOS

Homebrew

glab is available via Homebrew

brew install glab

Updating:

brew upgrade glab

MacPorts

glabis also available via MacPorts

sudo port install glab

Updating:

sudo port selfupdate && sudo port upgrade glab

Building from source

If a supported binary for your OS is not found at the releases page, you can build from source:

Prerequisites for building from source

  • make
  • Go 1.13+
  1. Verify that you have Go 1.13+ installed

    $ go version
    go version go1.14
    

    If go is not installed, follow instructions on the Go website.

  2. Clone this repository

    git clone https://gitlab.com/gitlab-org/cli.git glab
    cd glab
    

    If you have $GOPATH/bin or $GOBIN in your $PATH, you can just install with make install (install glab in $GOPATH/bin) and skip steps 3 and 4.

  3. Build the project:

    make
    
  4. Change PATH to find newly compiled glab

    export PATH=$PWD/bin:$PATH
    
  5. Run glab version to confirm that it worked.

Authentication

Get a GitLab access token at https://gitlab.com/-/profile/personal_access_tokens or https://gitlab.example.com/-/profile/personal_access_tokens if self-managed:

  • Start interactive setup:

    glab auth login
    
  • Authenticate against gitlab.com by reading the token from a file:

    glab auth login --stdin < myaccesstoken.txt
    
  • Authenticate against a self-managed GitLab instance by reading from a file:

    glab auth login --hostname salsa.debian.org --stdin < myaccesstoken.txt
    
  • Authenticate with token and hostname. Not recommended for shared environments:

    glab auth login --hostname gitlab.example.org --token xxxxx
    

Configuration

By default, glab follows the XDG Base Directory Spec:

  • The global configuration file is saved at ~/.config/glab-cli.

  • The local configuration file is saved at .git/glab-cli in the current working Git directory.

  • Advanced workflows may override the location of the global configuration by setting the GLAB_CONFIG_DIR environment variable.

  • To set configuration globally

    glab config set --global editor vim
    
  • To set configuration for current directory (must be a git repository)

    glab config set editor vim
    
  • To set configuration for a specific host

    Use the --host flag to set configuration for a specific host. This configuration is always stored in the global configuration file, with or without the global flag.

    glab config set editor vim --host gitlab.example.org
    

Environment variables

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 with 'glab config set token xxxxxx'

GITLAB_URI or GITLAB_HOST: specify the url of the gitlab server if self hosted (eg: https://gitlab.example.com). Default is https://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 URL

REMOTE_ALIAS or GIT_REMOTE_URL_VAR: git remote variable or alias that contains the gitlab url.
Can be set in the config with 'glab 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 with 'glab config set editor vim'

BROWSER: the web browser to use for opening links.
Can be set in the config with 'glab 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 style
https://github.com/charmbracelet/glamour#styles

NO_COLOR: set to any value to avoid printing ANSI escape sequences for color output.

FORCE_HYPERLINKS: set to 1 to force hyperlinks to be output, even when not outputing to a TTY

What about Lab?

Both glab and lab are open-source tools with the same goal of bringing GitLab to your command line and simplifying the developer workflow.

If you want a tool that's more opinionated and intended to help simplify your GitLab workflows from the command line, then glab is for you. However, if you want a tool like hub that feels like using Git and allows you to interact with GitLab, consider using lab.

Some glab commands such as ci view and ci trace were adopted from lab.

Issues

If you have an issue: report it on the issue tracker

Contributing

Feel like contributing? That's awesome! We have a contributing guide and Code of conduct to help guide you.