在使用Git
时,如果不想每次都输入全部的命令,可以给常用的命令配置一个别名
一、配置文件设置
bash
# ~/.gitconfig
[alias]
a = add .
c = commit
s = status
l = log
b = branch
此时使用git a
和git add .
效果一样
二、系统配置定义
使用系统终端配置定义更精简,可以通过修改~/.zshrc
文件设置别名
bash
alias gs="git status"
alias gc="git commit -m "
alias gl="git log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit"
alias gb="git branch"
alias ga="git add -A"
alias go="git checkout"
alias gp="git push;git push github"
此时在命令行使用gs
和git status
一样效果