Aliases are used to help you define your own git commands. For example, you can definegit a
To rungit add --all
.
To add an alias, open~/.gitconfig
File and add the following content:
[alias] co = checkout cm = commit p = push # Show verbose output about tags, branches or remotes tags = tag -l branches = branch -a remotes = remote -v
... Or type:
$ git config --global alias.new_alias git_function
For example:
$ git config --global alias.cm commit
Aliases pointing to multiple commands can be defined using quotation marks:
$ git config --global alias.ac ‘add -A . && commit‘
Some useful aliases are listed below:
Alias alias |
Command |
How to Set what to type |
git cm |
git commit |
git config --global alias.cm commit |
git co |
git checkout |
git config --global alias.co checkout |
git ac |
git add . -A git commit |
git config --global alias.ac ‘!git add -A && git commit‘ |
git st |
git status -sb |
git config --global alias.st ‘status -sb‘ |
git tags |
git tag -l |
git config --global alias.tags ‘tag -l‘ |
git branches |
git branch -a |
git config --global alias.branches ‘branch -a‘ |
git remotes |
git remote -v |
git config --global alias.remotes ‘remote -v‘ |
git lg |
git log --color --graph --pretty=format:‘%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset‘ --abbrev-commit -- |
git config --global alias.lg "log --color --graph --pretty=format:‘%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset‘ --abbrev-commit --" |
Source: tonyxue
Git command custom alias