Some git commands you type twenty times a day, with the same options every time. An alias gives them a short name that works in every repository.
git config --global alias.last "log -1 --stat"
git config --global alias.unstage "restore --staged"
Now git last shows the last commit with its files and git unstage file.txt takes a file out of the index. Extra arguments are added at the end, so git last HEAD~2 works too.
An alias that starts with an exclamation mark runs as a shell command instead of a git subcommand. That lets you chain things:
git config --global alias.cleanup '!git fetch -p && git branch -vv'
Shell aliases run from the top of the repository, not from the folder you’re in, which matters when the command uses relative paths. GIT_PREFIX holds the folder you started in if you need it.
All aliases live in the [alias] section of ~/.gitconfig, and git config --get-regexp ^alias lists them.
You can’t override a built-in command. An alias named log or status is silently ignored, which I find easy to forget. Also keep in mind that aliases are personal. A colleague doesn’t have your git last, so in docs and scripts for others, write the full command.
Further reading: git-config documentation: alias, Pro Git: Git Aliases