方式一、命令行执行
# Branch
alias br='git branch'
# Checkout
alias ck='git checkout'
# Commit
alias ci='git commit'
# Rebase
alias rb='git rebase'
# Switch
alias sw='git switch'
# Fetch
alias ft='git fetch'
# Fetch --all
alias fta='git fetch --all'
# Cherry-pick
alias cp='git cherry-pick'
# Pull
alias pl='git pull'
# Push
alias ps='git push'
# Merge
alias mr='git merge'
# Status
alias st='git status'
# Log
alias lg='git log --color --graph --pretty=format:"%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset" --abbrev-commit'
方式二、打开或新建 ~/.gitconfig 文件
复制以下内容,粘贴进~/.gitconfig 文件
[alias]
br = branch
ck = checkout
ci = commit
rb = rebase
sw = switch
ft = fetch
fta = fetch --all
cp = cherry-pick
pl = pull
ps = push
mr = merge
st = status
lg = log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit