Configure the CLI
- Tier: Free, Premium, Ultimate
- Offering: GitLab.com, GitLab Self-Managed, GitLab Dedicated
By default, glab follows the
XDG Base Directory Spec,
which means it searches for configuration files in multiple locations with proper precedence.
Configuration levels
Configure glab at different levels: system-wide, globally (per-user), locally (per-repository), or per host:
- System-wide (for all users): Place configuration at
/etc/xdg/glab-cli/config.yml(or$XDG_CONFIG_DIRS/glab-cli/config.yml).- Use this level for Linux distributions and system administrators to provide default configurations.
- User configurations override system-wide settings.
- Globally (per-user): run
glab config set --global editor vim.- The global configuration file is available at
~/.config/glab-cli/config.yml(or$XDG_CONFIG_HOME/glab-cli/config.yml). - To override this location, set the
GLAB_CONFIG_DIRenvironment variable.
- The global configuration file is available at
- The current repository: run
glab config set editor vimin any folder in a Git repository.- The local configuration file is available at
.git/glab-cli/config.ymlin 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--hostparameter to meet your needs.- Per-host configuration information is always stored in the global configuration file, with or without the
globalflag.
- Per-host configuration information is always stored in the global configuration file, with or without the
Configuration search order
When glab looks for configuration files, it searches in this order (highest priority first):
$GLAB_CONFIG_DIR/config.yml(ifGLAB_CONFIG_DIRis set)~/.config/glab-cli/config.yml(legacy location, for backward compatibility)$XDG_CONFIG_HOME/glab-cli/config.yml(platform-specificXDG_CONFIG_HOMElocation)$XDG_CONFIG_DIRS/glab-cli/config.yml(system-wide configuration files, default:/etc/xdg/glab-cli/config.yml)
The first configuration file found is used.
Configuration file locations
For backward compatibility, glab checks ~/.config/glab-cli/config.yml first on all platforms.
If no legacy configuration file exists, glab uses these platform-specific
XDG_CONFIG_HOME locations:
- Linux:
~/.config/glab-cli/config.yml - macOS:
~/Library/Application Support/glab-cli/config.yml - Windows:
%LOCALAPPDATA%\glab-cli\config.yml
If you have configuration files in both the legacy location (~/.config/glab-cli/config.yml)
and the platform-specific XDG_CONFIG_HOME location, glab uses the legacy location and
displays a warning. Consider consolidating to one location to avoid confusion.