git别名定义

Tutorials / 2023-09-02 / 原文

系统配置定义

window 用户可以修改~/.bashrc~/.bash_profile文件。
或者修改D:\ProgramFiles\PortableGit\etc\profile.d\aliases.sh

mac/linux修改~/.zshrc文件中定义常用的别名指令,需要首先安装zsh命令行扩展

在最后一行追加

# ----------------------
# Git Command Aliases
# ----------------------
alias gs="git status"
alias gc="git commit -m "
alias gl="git log --graph --date=format:'%Y-%m-%d %H:%M:%S' --pretty=format:'%Cred%h%Creset %C(cyan)%cd%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"

命令行直接使用 gl 即可以实现 输出git历史 一样的效果了。