Skip to content

Git Alias

In one line

A git alias is a custom shortcut defined in git config that expands to a longer Git command or sequence.

In simple words

A git alias lets you define a short name for a longer Git command. You configure it with git config, and then use it as if it were a built-in command. Aliases save typing and reduce errors for commands you run frequently.

For example, alias "co" to "checkout", "br" to "branch", "ci" to "commit -s", and "st" to "status -sb". Then git co main runs git checkout main. You can also alias to shell commands by prefixing with !, enabling powerful combinations.

Aliases are stored in the [alias] section of your gitconfig. They do not change Git's behavior — they are pure shortcuts. Many developers share a common set of aliases in their dotfiles for a consistent workflow across machines.

Example

bash
# Define common shortcuts
git config --global alias.co checkout
git config --global alias.br branch
git config --global alias.ci "commit -s"
git config --global alias.st "status -sb"

# Use them like built-in commands
git co main          # git checkout main
git br -d feature    # git branch -d feature
git ci -m "fix"      # git commit -s -m "fix"

# Alias to a shell command (prefix with !)
git config --global alias.lg "!git log --oneline --graph --all"

Aliases are set via git config alias.NAME VALUE. Use them as git NAME. Prefix with ! to run a shell command.

Related terms

Related Resources

Related Lessons

Decode error messages

Plain-English explanations of common errors — what they mean, why they happen, and how to fix them.

View errors

← Back to glossary