git-alias
Create shorthand commands for Git operations
TLDR
List all aliases
Create a new alias
Search for an existing alias
SYNOPSIS
git config --global alias.
PARAMETERS
alias.
The name of the alias you want to create. This is the new command you will type.
'
The actual Git command (or series of commands separated by '!') that the alias will execute.
--global
Saves the alias in the global Git configuration file (~/.gitconfig), making it available for all repositories.
--local
Saves the alias in the local Git configuration file (.git/config) of the current repository, making it available for only this repository.
--system
Saves the alias in the system-wide Git configuration file, making it available for all users on the system. Requires appropriate permissions.
DESCRIPTION
The `git alias` command allows you to define custom shortcuts for frequently used Git commands. It provides a way to shorten long or complex Git commands into simpler aliases. This enhances efficiency and reduces typing errors. Aliases are stored within your Git configuration (either local, global, or system), and can accept arguments just like regular Git commands.
For example, if you frequently use `git log --graph --decorate --oneline`, you can create an alias named `git lg` that executes this command, making your workflow faster. When using aliases you can avoid making spelling errors since you write less characters.
CAVEATS
Aliases don't override built-in Git commands. If an alias name conflicts with an existing Git command, the built-in command will take precedence.
Aliases containing '!' can execute arbitrary shell commands, so be cautious when using aliases from untrusted sources.
EXAMPLES
- Creating an alias for `git branch`:
git config --global alias.br branch
- Creating an alias that shows a graph of the commit history:
git config --global alias.lg "log --graph --decorate --oneline"
- Creating an alias with a shell command:
git config --global alias.last 'log -1 HEAD'
- Alias with Arguments
git config --global alias.l 'log --pretty=format:"%h %ad | %s%d [%an]" --graph --date=short'
git l
SEE ALSO
git config(1)