Git aliases: short names for long commands
Updated July 31, 2026
An alias is your own short name for a git command, set with git config. A command with five flags that you type twenty times a day becomes two letters.
$ git config --global alias.st status
$ git config --global alias.co checkout
$ git config --global alias.lg "log --oneline --graph --all"To the left of the dot is the word alias, to the right the name you invented. The value is everything that should follow git. The quotes are needed when the value contains spaces, which is as soon as flags appear.
$ git st
On branch main
nothing to commit, working tree clean
$ git lg
* 36e705e second commit
* 20d5f39 first commitgit lg instead of git log --oneline --graph --all is the case aliases exist for: a useful command that nobody is going to type out in full.
Where they live
--global writes to ~/.gitconfig, into the [alias] section:
$ cat ~/.gitconfig
[user]
name = Anna Petrova
email = anna@example.com
[alias]
st = status
co = checkout
lg = log --oneline --graph --allIt is a plain text file, so you can open it in an editor and edit it by hand: adding a line to the [alias] section does exactly what git config --global alias.<name> does. Without --global the alias lands in .git/config of a single repository and works nowhere else.
To see what an alias expands to, ask git config:
$ git config --get alias.lg
log --oneline --graph --allAn exclamation mark at the start of the value changes the meaning: the string is run as a shell command instead of a git subcommand. That is how people build aliases that chain several commands or call outside programs, for instance git config --global alias.today '!git log --since=midnight --oneline'. Such an alias runs from the repository root rather than your current directory, and it depends on your shell. That is advanced ground; plain aliases are the place to start.
Common mistakes
An alias cannot override a command git already has. The entry alias.status = log --oneline goes into the file, but git ignores it: a built-in command always wins, and git status stays git status. If you want your own version, pick another name.
A typo inside an alias only surfaces when you run it: expansion of alias 'br' failed; 'brnch' is not a git command. Check the value with git config --get.
And the important one: aliases live on your machine, and your colleagues do not have them. In team instructions and in ticket descriptions, write the full commands. Otherwise git lg is a command that does not exist for whoever is reading, and you are the one who gets to explain.