mac git alias配置

426 阅读1分钟

.bash_profile

首先创建.bash_profiletouch ~/.bash_profile

然后在.bash_profile中输入alias

alias ga="git add"
alias gb="git branch"
alias gcd="git checkout develop"
alias gc="git checkout"
alias gcm="git commit -m"
alias gl="git pull"
alias glud="git pull upstream develop"
alias glum="git pull upstream master"
alias gp="git push"
alias gpod="git push origin develop"
alias gpom="git push origin master"
alias gst="git status"
alias glog="git log"
alias grlog="git reflog"
alias b="branch"
alias cp="cherry-pick"
alias g="git"

接着执行source ~/.bash_profile就可以生效。但这样终端关闭重开后alias就会失效了

.zshrc

.zshrc中写的命令,计算机每次启动都会重新执行,而且永久生效

因此可以把source ~/.bash_profile写入.zshrc中,即可使alias永久生效

百度查询一般是说~/.bash_profile每次终端重启都会重新执行,因此把source ~/.bashrc写入~/.bash_profile并把alias写入~/.bashrc,但实测在mac上并不行