LinuxCommandLibrary
GitHubF-DroidGoogle Play Store

git-alias

list, search, and create git aliases

TLDR

List all aliases
$ git alias
copy
Search aliases matching a pattern
$ git alias [pattern]
copy
Create an alias
$ git alias [co] "[checkout]"
copy
Create an alias in the global config
$ git alias --global [st] "[status -sb]"
copy
Create an alias only for this repository
$ git alias --local [dc] "[diff --cached]"
copy
Create an alias that runs a shell command
$ git alias [amend] "[!git commit --amend --no-edit]"
copy

SYNOPSIS

git alias [options]git alias [options] search-patterngit alias [options] alias-name command

DESCRIPTION

git alias is a git-extras helper for managing the [alias] section of your git config. It is a thin wrapper around git config, but with a syntax short enough to use casually.With no arguments it lists every alias git can see, formatted as name = command and sorted. With one argument it filters that list. With two it creates an alias: git alias co checkout makes git co run git checkout.An alias whose command starts with ! is run as a shell command rather than a git subcommand, which is how aliases that chain commands or take arguments are written.Without --global or --local, listing shows the merged view of all config levels, and creating writes wherever plain git config would, which is normally the repository's .git/config when you are inside a repository.

PARAMETERS

--global

Show or create the alias in the global (user) config.
--local
Show or create the alias in the repository config.
search-pattern
Show only aliases matching this pattern. It is passed to grep, so it is a regular expression, not a glob.
alias-name command
Create an alias mapping alias-name to command.

CONFIGURATION

~/.gitconfig

Global aliases, written by --global, in the [alias] section.
.git/config
Repository-local aliases, written by --local.

INSTALL

sudo apt install git
copy
sudo dnf install git
copy
sudo pacman -S git
copy
sudo apk add git
copy
sudo zypper install git
copy
brew install git
copy
nix profile install nixpkgs#git
copy

CAVEATS

The --global option writes to your user config (~/.gitconfig), despite the built-in help describing it as "the system config". True system-wide config is git config --system, which this wrapper does not expose.Creating an alias silently overwrites an existing one of the same name; there is no confirmation and no way to undo it other than rewriting the value.The search pattern goes to grep unquoted, so characters like . and ***** are regex metacharacters and match more than you might expect.Aliases cannot shadow built-in git commands. git alias status "log" is accepted by the config but git will keep running the real status.Passing more than two arguments is an error, so a multi-word command must be quoted as a single argument.

HISTORY

git alias is part of git-extras, created by TJ Holowaychuk in 2010 and now community-maintained. Git's own alias mechanism, which this wraps, has existed in git config since the early days of git.

SEE ALSO

RESOURCES

Braincup
Open source brain training for math, memory and focus
Braincup mini-games
41 mini-games · Apache-2.0
No ads · No tracking
Play in browser
Download Braincup on the App StoreGet Braincup on Google PlayGet Braincup on F-Droid
276 stars
From the maker of Linux Command Library
Copied to clipboard
Braincup
Open source brain training for math, memory and focus. 41 mini-games, from mental arithmetic to Sudoku, N-Back and Solo Chess.
Apache-2.0 licensed · No ads · No tracking · No account
From the maker of Linux Command Library
Download Braincup on the App StoreGet Braincup on Google PlayGet Braincup on F-Droid