每次我们在使用git命令行拉代码、推代码的时候,打的字多就会觉得麻烦。以下步骤可以设置简化git命令行。
首先打开终端
第一步:创建配置文件,并打开配置文件。
查看shell模式
echo $0
shell为zsh时,配置文件为.zshrc
touch ~/.zshrc
open ~/.zshrc
shell为bash时,配置文件为.bashrc
touch ~/.bashrc
open ~/.bashrc
第二步:添加配置文件内容
alias ga="git add"
alias gc="git commit"
alias gl="git pull"
alias gp="git push"
alias gco="git checkout"
alias gst="git status -sb"
alias glog="git log --graph --pretty=format:'%Cred%h%Creset -%C(green)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit -- | less"
第三步:读取并执行配置文件
source ~/.zshrc
source ~/.bashrc
完成了!
接下来就可以使用简化后的git命令行进行操作。
ga . // 即git add .
gc -m "update message" // 即git commit -m "update message"
gl // 即 git pull
gp // 即 git push