LinuxCommandLibrary

git-alias

Create shorthand commands for Git operations

TLDR

List all aliases

$ git alias
copy

Create a new alias
$ git alias "[name]" "[command]"
copy

Search for an existing alias
$ git alias ^[name]
copy

SYNOPSIS

git alias [options] [command alias [git args...]]

PARAMETERS

-a, --add
    Add a new alias in format alias command args

-d, --delete
    Delete the specified alias

-l, --list
    List all current aliases

-g, --global
    Operate on global (user-wide) aliases instead of local

-s, --show
    Show the expansion of the given alias

-h, --help
    Display help information

DESCRIPTION

The git alias command, part of the popular git-extras package, simplifies the creation, listing, and deletion of Git aliases. Git aliases are shortcuts that map short names to full Git commands, stored in the Git configuration. This tool provides a user-friendly interface over git config, avoiding manual editing of config files.

Without arguments, git alias lists all defined aliases in the current repository or global scope. Users can add aliases like st for status --short, delete them, or inspect expansions. It supports both local (per-repo) and global scopes via flags.

This enhances productivity for frequent Git users by reducing typing for complex commands, such as git lg for a custom log view. While core Git supports aliases natively via git config alias.name 'command', git alias streamlines management with intuitive syntax and feedback.

Note: git-alias may refer to third-party variants or scripts, but standard usage aligns with git-extras' git alias. Install git-extras for full functionality.

CAVEATS

Requires git-extras package installed; not part of core Git. Default scope is local unless --global specified. Aliases override built-in Git subcommands if named similarly.

EXAMPLES

git alias # List aliases
git alias add st 'status --short'
git alias --global delete st
git alias show lg # Show alias expansion

INSTALLATION

Linux: sudo apt install git-extras or yum install git-extras
macOS: brew install git-extras
Check: git alias --help

HISTORY

Introduced in git-extras (started 2011 by Linus Olsson), with git alias added early for alias management. Evolved with scope support in later versions; widely used in developer workflows.

SEE ALSO

Copied to clipboard