An open-source GitLab command line tool bringing GitLab's cool features to your command line

GLab

Go Report Card codecov pipeline status Documentation Status Gitter

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. Inspired by gh, the official GitHub CLI tool.

glab is available for repositories hosted on GitLab.com and self-hosted GitLab Instances. glab supports multiple authenticated GitLab instances and automatically detects the authenticated hostname from the remotes available in the working git directory.

image

Table of Contents

Usage

glab <command> <subcommand> [flags]

Core Commands

  api:         Make authenticated REST/GRAPHQL requests to the GitLab API
  auth:        Manage glab's authentication state
  issue:       Work with GitLab issues
  label:       Manage labels on remote
  mr:          Create, view and manage merge requests
  ci:          Work with GitLab CI pipelines and jobs
  release:     Manage GitLab releases
  repo:        Work with GitLab repositories and projects
  

Additional Commands

  alias:       Create, list and delete aliases
  check-update: Check for latest glab releases
  completion:  Generate shell completion scripts
  config:      Set and get glab settings
  help:        Help about any command
  version:     show glab version information

Examples

$ glab issue create --title="This is an issue title" --description="This is a really long description"
$ glab issue list --closed
$ glab ci view -b master    # to watch the latest pipeline on master
$ glab ci status    # classic ci view

Demo

asciicast

Learn More

Read the documentation for more information on this tool.

Installation

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

Quick Install (shell)

Supported Platforms: Linux and macOS

You can install or update glab with:

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

or

curl -s https://raw.githubusercontent.com/profclems/glab/trunk/scripts/install.sh | sudo sh

Installs into usr/bin

NOTE: Please take care when running scripts in this fashion. Consider peaking 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

Updating:

winget install glab

Scoop

scoop install glab

Updating:

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:

brew upgrade glab

Snapcraft

Get it from the Snap Store

Make sure you have snap installed on your Linux Distro (https://snapcraft.io/docs/installing-snapd).

  1. sudo snap install --edge glab
  2. sudo snap connect glab:ssh-keys to grant ssh access

Arch Linux

glab is available through the gitlab-glab-bin package on the AUR or download and install an archive from the releases page. Arch Linux also supports snap.

yay -Sy gitlab-glab-bin

or any other AUR helper of your choice.

KISS Linux

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

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

If you do not have the community repo configured in your KISS_PATH, follow the guide on the official guide Here to learn how to setup it up.

Alpine Linux

glab is available on the Alpine Community Repo as glab.

Install

We use --no-cache so we don't need to do an apk update before.

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

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

Afterwards you can install it with apk add --no-cache [email protected]

We use --no-cache so we don't need to do an apk update before.

echo "@edge http://dl-cdn.alpinelinux.org/alpine/edge/community" >> /etc/apk/repositories
apk add --no-cache [email protected]
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 [email protected]

Nix/NixOS

Nix/NixOS users can install from nixpkgs:

nix-env -iA nixos.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 are:

  • 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://github.com/profclems/glab.git
    $ 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 check if it worked and glab config init to set up

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-hosted

  • 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-hosted 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

glab follows the XDG Base Directory Spec: global configuration file is saved at ~/.config/glab-cli. Local configuration file is saved at the root of the working git directory and automatically added to .gitignore.

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 is always stored in the global config 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. 

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. In many ways lab is to hub, while glab is to gh.

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're looking for a tool like hub that feels like using git and allows you to interact with GitLab, you might 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

Support glab 💖

By donating $5 or more you can support the ongoing development of this project. We'll appreciate some support. Thank you to all our supporters! 🙏 [Contribute]

Individuals

This project exists thanks to all the people who contribute. [Contribute].

Backers

Thank you to all our backers! 🙏 [Become a backer]

License

Copyright © Clement Sam

glab is open-sourced software licensed under the MIT license.

Owner
Clement Sam
A polyglot. Mostly working with @golang, @php, @laravel, @aws, C#, @docker, @kubernetes. @GitLab Hero.
Clement Sam
Comments
  • {

    {"message":"405 Method Not Allowed"}

    When i accept a mr , use command 'glab mr merge 15' It showed

    • Merging merge request !15

    PUT https://xxx/merge_requests/15/merge: 405 {message: 405 Mexthod Not Allowed}

    Your Environment

    • Version used:➜ glab --version glab 1.11.0-pre2 ()
    • Operating System and version:
  • glab-resolved = {base|head} support

    glab-resolved = {base|head} support

    Description

    This is a big one:

    • Create HeadRepo in internal/glrepo, works the same as BaseRepo but checks glab-resolved = head and also picks the first forked repo instead of just the first repo
    • vendor functions used for glab-resolved = base into create_mr and make them work for glab-resolved = head
    • deprecate --target-project as users can just use --repo instead

    Related Issue

    Resolves #406 #393

    How Has This Been Tested?

    Alpine

    Types of changes

    • [x] Bug fix (non-breaking change which fixes an issue)
    • [x] New feature (non-breaking change which adds functionality)
    • [ ] Breaking change (fix or feature that would cause existing functionality to change)
    • [ ] Documentation
    • [ ] Chore (Related to CI or Packaging to platforms)

    TODO

    • Need to re-introduce the alternate code for resolution but make it prefix with base: and head:
  • no gitlab projects found from remotes

    no gitlab projects found from remotes

    Description Getting the error "no gitlab projects found from remotes" when running glab issue list glab auth status returns all green check marks Expected Behavior vs Actual Behavior List the issues

    Steps to Reproduce $ glab auth login --stdin < token.txt $ glab issue list

    Your Environment glab version 1.18 gitlab version 14.01

  • Acknowledge glab contributors

    Acknowledge glab contributors

    This issue is opened specifically to acknowledge glab contributors in the README.md using @allcontributors bot.

    If you have contributed to glab and your name hasn't appeared in the contributors' list on the project's readme, check the bot usage here https://allcontributors.org/docs/en/bot/usage and comment as such to automatically open a PR which adds you to the contributors' list

  • when creating mr, have an equivalent to glab-resolved to set a default target project.

    when creating mr, have an equivalent to glab-resolved to set a default target project.

    Describe the feature or problem you'd like to solve When contributing to a repository that isn't yours it is hard to use the --target-project switch as it requires knowing the ID and using it every time.

    Propose a Solution Create a glab-targeted entry that acts the same way glab-resolved is used but use it when deciding which TargetProjectID to use.

    Additional context Here is a crude workflow graph I made

    image

  • Rework BaseRepo from internal.glrepo.resolver

    Rework BaseRepo from internal.glrepo.resolver

    Description

    This reworks BaseRepo to support certain features:

    • Be stricter about cached resolutions, only use base or the first with the prefix base: (instead of any other resolution)

    Related Issue

    No issue was open for this but it is ripped of #410 to be easier to reason about

    How Has This Been Tested?

    Tested as part of #410

    Types of changes

    • [ ] Bug fix (non-breaking change which fixes an issue)
    • [x] New feature (non-breaking change which adds functionality)
    • [ ] Breaking change (fix or feature that would cause existing functionality to change)
    • [ ] Documentation
    • [ ] Chore (Related to CI or Packaging to platforms)
  • Clickable terminal links

    Clickable terminal links

    Describe the feature or problem you'd like to solve

    We could make issue list and mr list clickable.

    Propose a Solution

    !123  Add support for links             (main) <- (links)
    
    • Click !123 to go to the issue or merge request:
    • Click (links) to go to the branch. Example: https://example.com/user/repo/-/tree/links

    Additional context

  • issue with long/deep paths?

    issue with long/deep paths?

    hello, i'm trying to use glab ci status to verify the pipeline status directly from the command line, it works fine on repos with "short" paths, seem to break on "long"/"deep" ones

    here are some repo url examples, i've maintained the character count in each url "section" working:

    • http://123456.123.123456.12/12345678901234/123456789012
    • http://123456.123.123456.12/1234567/123456789/12345678901

    not working:

    • http://123456.123.123456.12/1234567/123456789/12345678901234567/12345678901234
      • returns "invalid path: /1234567/123456789/12345678901234567/12345678901234" (full url excluded the hostname)

    all these are configured as ssh in git config, using http api calls

    glab version 1.14.0

    regards, m

  • Could not find remote url for gitlab. Run git config

    Could not find remote url for gitlab. Run git config

    Description glab always complains about Could not find remote url for gitlab. Run git config.

    $ glab --version
    glab version 1.8.1 ()
    git version 2.28.0
    Made with ❤ by Clement Sam <[email protected]> and contributors
    $ glab config --token=$GITLAB_CODE_API_PRIVATE_TOKEN --url=https://gitlab.example.org
    Environment variable(s) updated
    $ git remote -v
    origin	[email protected]:group/subgroup1/subgroup2/ingress-nginx.git (fetch)
    origin	[email protected]:group/subgroup1/subgroup2/ingress-nginx.git (push)
    $ glab mr list
    2020/08/12 15:13:43 Could not find remote url for gitlab. Run git config
    

    Expected Behavior It works

    Actual Behavior Could not find remote url for gitlab. Run git config

    Possible Fix

    Steps to Reproduce

    $ glab --version
    glab version 1.8.1 ()
    git version 2.28.0
    Made with ❤ by Clement Sam <[email protected]> and contributors
    $ glab config --token=$GITLAB_CODE_API_PRIVATE_TOKEN --url=https://gitlab.example.org
    Environment variable(s) updated
    $ git remote -v
    origin	[email protected]:group/subgroup1/subgroup2/ingress-nginx.git (fetch)
    origin	[email protected]:group/subgroup1/subgroup2/ingress-nginx.git (push)
    $ glab mr list
    2020/08/12 15:13:43 Could not find remote url for gitlab. Run git config
    

    Context

    Your Environment

    • Version used:
    • Operating System and version:
  • Can't merge a Merge Request if I am in detached HEAD state

    Can't merge a Merge Request if I am in detached HEAD state

    Description So, I am running glab in a gitlab-ci pipeline with the goal to create a MR from development to main and automerge it, if the pipeline succeeds.

    As I run in an MR pipeline, the git state is a detached HEAD. I try to execute glab mr merge <id> with an correct ID and get the error: could not determine current branch: git: not on any branch.

    Creating the MR with glab mr create -b main -s development -y -t test -d "" did work however

    Expected Behavior vs Actual Behavior It should not give me the error as I am not interacting with the current git state anyway

    Possible Fix Maybe mr merge can be refactored to use whatever mr create is doing.

    Your Environment I am trying to get this pipeline to work:

      stage: release
      image: alpine
      needs: []
      variables:
        DESCRIPTION: test
        SOURCE_BRANCH: $CI_DEFAULT_BRANCH
        TARGET_BRANCH: main
        TITLE: '[Dependency Update] test release'
        TOKEN: $TEST_PAT
      before_script:
        - 'echo "@edge http://dl-cdn.alpinelinux.org/alpine/edge/community" >> /etc/apk/repositories'
        - apk add --no-cache [email protected]
      script:
        - echo $TOKEN | glab auth login --stdin
        - glab mr create -b $TARGET_BRANCH -s $SOURCE_BRANCH -y -t "$TITLE" -d "$DESCRIPTION"
        - export MR_ID=$(glab mr ls -s $SOURCE_BRANCH -t $TARGET_BRANCH | grep ! | awk '{print substr($1,2);}')
        - glab mr merge $MR_ID -R osp-cl/movex/customer-service-2.0/queries/read-config
    
  • Can't create MR from branch that is already pushed

    Can't create MR from branch that is already pushed

    Description When I working I often push to remote, but don't open a MR, because I don't need that yet. When I finish up with my task, I want to create an MR, but I get an error

    You must be on a different branch other than "xxx"
    

    Expected Behavior vs Actual Behavior Expected :

    glab mr create
    > Prompt for opening creating MR to show up
    

    Actual:

    glab mr create
    You must be on a different branch other than "xxx"
    

    Possible Fix Something with the logic around https://github.com/profclems/glab/blob/6e1919f24e08d870e276b255563f7d943bf65a0a/commands/mr/create/mr_create.go#L246-L254

    Steps to Reproduce

    1. Create a local branch
    2. Push to remote
    3. Run glab mr create and see error

    Your Environment

    • Version used (Run glab --version): glab version 1.15.0-1-g6e1919f (2021-02-17)
    • Operating System and version: Manjaro Linux
  • Update install.sh

    Update install.sh

    Description

    Related Issue

    Resolves #[issue_number]

    How Has This Been Tested?

    Screenshots (if appropriate)

    Types of changes

    • [ ] Bug fix (non-breaking change which fixes an issue)
    • [ ] New feature (non-breaking change which adds functionality)
    • [ ] Breaking change (fix or feature that would cause existing functionality to change)
    • [ ] Documentation
    • [ ] Chore (Related to CI or Packaging to platforms)
  • no GitLab Projects found from remotes

    no GitLab Projects found from remotes

    When I create a merge request with glab mr create it prompts the following

    image

    image

    The glab version I am using is glab version 1.22.0 (2022-01-10) and the gitlab version is 12.9.1 .

    I have checked the related issue https://github.com/profclems/glab/issues/792, still unable to solve the problem.

  • DO NOT CONTRIBUTE HERE

    DO NOT CONTRIBUTE HERE

    I just noticed that the project has moved to gitlab. This is no longer the place for contribution.

    Go to https://gitlab.com/gitlab-org/cli/ for the new home of the project and https://gitlab.com/gitlab-org/cli/-/issues/985 for status on the transition.

  • Update default branch of repo

    Update default branch of repo

    Describe the feature or problem you'd like to solve There is currently not update anything about a gitlab project/repo. I would like to update the default branch of a repo. It might also be nice to update other settings for the a repo.

    Propose a Solution Add a glab repo update command and allow for editing some of the settings of the repo. Specifically I would like to be able to update the default branch of a project.

  • MacOS M1 Install Script support (arm64)

    MacOS M1 Install Script support (arm64)

    Describe the feature or problem you'd like to solve Currently, the install script does not support MacOSX M1 machines, because there is no download available at https://github.com/profclems/glab/releases/download/v1.22.0/glab_1.22.0_macOS_arm64.tar.gz

    That causes the script to fail.

    Propose a Solution Add cross-compilation for the macOS_arm64 target

A command line tool that builds and (re)starts your web application everytime you save a Go or template fileA command line tool that builds and (re)starts your web application everytime you save a Go or template file

# Fresh Fresh is a command line tool that builds and (re)starts your web application everytime you save a Go or template file. If the web framework yo

Nov 22, 2021
A command-line tool for gitlab
A command-line tool for gitlab

Lab A fuzzy finder command line tool for gitlab. 中文文档 Feature lab sync Sync gitlab projects lab browser Fuzzy find gitlab repo and open it

Nov 28, 2022
A command line tool to prompt for a value to be included in another command line.

readval is a command line tool which is designed for one specific purpose—to prompt for a value to be included in another command line. readval prints

Dec 22, 2021
There is a certain amount of work to be done before you can implement the features of your Go powered CLI app

go-project-template-cli There is a certain amount of work to be done before you can implement the features of your Go powered CLI app. A few of those

Jan 23, 2022
Terraform gitlab environment

terraform-gitlab-environment terraform-gitlab-environment for gitlab Requirements This is a list of plugins that need to be installed previously to en

Feb 23, 2022
Watch your favourite anime using the video player of your choice directly from the command line

anime-cli Watch your favourite anime using the video player of your choice direc

Feb 10, 2022
Experimental go cli tool to track your open issues and PRs.
Experimental go cli tool to track your open issues and PRs.

git-sum cli tool See open issue and pull request counts for each repository of the user. Installation go install github.com/suadev/[email protected] Usa

Jan 21, 2022
Nov 26, 2022
An interactive command-line tool to manage your environments
An interactive command-line tool to manage your environments

goto An interactive command-line tool to manage your environments Overview You always need to login to some Linux machine or connect to a MySQL instan

Jul 11, 2022
🌿circumflex is a command line tool for browsing Hacker News in your terminal
🌿circumflex is a command line tool for browsing Hacker News in your terminal

??circumflex is a command line tool for browsing Hacker News in your terminal

Nov 27, 2022
Command line tool to show the weather information of your city

go-weather when you type weather <city>, it will show you the weather of the city you input. Useful API comes from openweathermap.org. You can registe

Nov 5, 2021
t is a command line tool for testing on your terminal.
t is a command line tool for testing on your terminal.

t t is a command line tool for testing on your terminal. Installation $ go get github.com/yusukebe/t/cmd/t Usage Basic usage: $ t hello hello # => PA

May 5, 2022
Command line tool to copy images from a camera SD card to your hard drive

Command line tool to copy images from a camera SD card to your hard drive

Nov 26, 2021
A simple tool which you can use to move through your directories from the command line

Fe What is Fe ? Fe is a simple tool which you can use to move through your direc

Jan 1, 2022
Upterm is an open-source solution for sharing terminal sessions instantly over the public internet via secure tunnels.
Upterm is an open-source solution for sharing terminal sessions instantly over the public internet via secure tunnels.

Upterm is an open-source solution for sharing terminal sessions instantly over the public internet via secure tunnels.

Dec 2, 2022
Teller - the open-source universal secret manager for developers
 Teller - the open-source universal secret manager for developers

A secrets management tool for developers built in Go - never leave your command line for secrets.

Nov 22, 2022
a Go language free and open-source document for learning from zero level

Go document a GO language free and open-source document for learning from zero level Please publish and collaborate OPEN-SOURCE Sections About go lang

Sep 27, 2022
git-xargs is a command-line tool (CLI) for making updates across multiple Github repositories with a single command.
git-xargs is a command-line tool (CLI) for making updates across multiple Github repositories with a single command.

Table of contents Introduction Reference Contributing Introduction Overview git-xargs is a command-line tool (CLI) for making updates across multiple

Nov 30, 2022
git-xargs is a command-line tool (CLI) for making updates across multiple GitHub repositories with a single command
git-xargs is a command-line tool (CLI) for making updates across multiple GitHub repositories with a single command

git-xargs is a command-line tool (CLI) for making updates across multiple GitHub repositories with a single command. You give git-xargs:

Feb 5, 2022