Git
aliases
version control
git commands
productivity

List Git aliases

Interview Questions practice on Codemia

Over 8,000 real interview questions from top companies, searchable by company and role.

Browse interview questions

Introduction

Git aliases live in Git configuration, so listing them is really a configuration query problem. The most direct command is git config --get-regexp '^alias\.', which shows alias names and their configured command bodies.

List all aliases from the active config scope

Use this command first:

bash
git config --get-regexp '^alias\.'

Typical output looks like this:

text
alias.co checkout
alias.br branch
alias.st status -sb

Git prints the config key followed by the alias value. The ^alias\. pattern limits the result to entries under the alias section.

Show only global aliases

If you want aliases from your user-level Git config only, add --global.

bash
git config --global --get-regexp '^alias\.'

This is useful when you want to inspect aliases from ~/.gitconfig without mixing in repository-local settings.

Show the source file for each alias

When debugging why an alias exists, ask Git to show where each value came from.

bash
git config --show-origin --get-regexp '^alias\.'

That output includes the config file path, which helps when aliases are defined in multiple places.

Repository-local aliases can override expectations

A repository can define aliases in .git/config. Those aliases are available only inside that repository.

bash
git config --local --get-regexp '^alias\.'

If a command behaves differently in one project than everywhere else, local config is the first place to inspect.

Inspect one alias directly when you know its name

If you only need to inspect one alias, query it directly instead of listing everything.

bash
git config alias.st

This is useful when a shell script, team setup guide, or terminal history mentions an alias and you want to see its exact expansion quickly.

It also avoids scanning unrelated aliases.

Read aliases directly from the config file if needed

You can also inspect the raw config sections.

bash
git config --list | grep '^alias\.'

The regular-expression form is usually cleaner, but --list can help when you want a broader picture of configuration at the same time.

Aliases may wrap shell commands

Some aliases start with !, which means Git runs them as shell commands rather than normal Git subcommands.

ini
[alias]
    lg = log --oneline --graph --decorate
    cleanup = !git branch --merged | grep -v '\*' | xargs -n 1 git branch -d

Listing aliases is especially important when shell aliases exist, because they can be much more powerful and much easier to misunderstand.

Use quoting carefully in scripts

If you are scripting alias inspection, keep the regular expression quoted so the shell does not interpret the backslash or caret unexpectedly.

bash
git config --get-regexp '^alias\.'

That small detail avoids a surprising class of shell-specific failures.

Common Pitfalls

  • Looking for aliases with git alias even though Git has no built-in subcommand by that name.
  • Forgetting that aliases can exist in local, global, and system config scopes.
  • Ignoring --show-origin and then not knowing which config file actually defined the alias.
  • Treating shell-style ! aliases like ordinary Git subcommand aliases.
  • Using grep on git config --list when --get-regexp already gives a cleaner filtered result.

Summary

  • Use git config --get-regexp '^alias\.' to list Git aliases.
  • Add --global or --local when you want a specific config scope.
  • Use --show-origin to see which file defined each alias.
  • Expect some aliases to be shell commands if they start with !.
  • Inspect config scope before assuming an alias is missing or global.

Related reading
Free course
Beginner
7 lessons
2 hours
Tackling System Design Interview Problems

A short course that equips you with the skills to approach system design interviews methodically.

Start the free course
Track what you have practised

A free account saves your progress, solutions and study plan across every problem on Codemia.

Interview Questions practice on Codemia

Over 8,000 real interview questions from top companies, searchable by company and role.

Browse interview questions

All Rights Reserved.