【工具类】git log 常用别名,git log 干活,git log常用参数

本文详细介绍了如何在git中使用gitconfig设置全局别名,优化常用git命令如log、commit、status等的快捷方式,以及gitlog的常用参数及其功能。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

git log 常用参数及 .gitconfig 配置

干货,执行下边命令,添加别名

  • 注意,需要将 knowledgebao 修改为自己的名字,根据自己需要添加,常用的别名有:st ll lg lga lgb
  • 执行下边语句,添加各种快捷键,执行 git lm, git lms, git ls, git lsm … 等试试效果吧
git config --global alias.co "checkout"
git config --global alias.ck "checkout --track -b" # checkout and tracked
git config --global alias.ci "commit"
git config --global alias.cl "clean -x -d -f"  # force clean and remove ignored files.
git config --global alias.st "status"
git config --global alias.sst "status --ignore-submodules=all"
git config --global alias.pl "pull"
git config --global alias.ps "push"
git config --global alias.lb "remote show origin"  # list branch
git config --global alias.li "status --short --porcelain --ignored"  # list ignored
git config --global alias.lo "ls-files -o '--exclude=build/*' '--exclude=.vscode/*'"  # list others
git config --global alias.cp "cherry-pick"
git config --global alias.ca "commit -a"
git config --global alias.br "branch"
git config --global alias.df "diff --ignore-cr-at-eol --ignore-space-at-eol"
git config --global alias.dc "diff --cached --ignore-cr-at-eol --ignore-space-at-eol"
git config --global alias.m "merge"
git config --global alias.dt "difftool"
git config --global alias.mt "mergetool"
git config --global alias.desc "describe --tags --long"

# 通过 git lm 查看自己的修改记录,关键字 --author --abbrev-commit
git config --global alias.lm "log --no-merges --color --author='knowledgebao' --date=format:'%Y-%m-%d %H:%M:%S' --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Cblue %s %Cgreen(%cd) %C(bold blue)<%an>%Creset' --abbrev-commit"

# 通过 git lms 查看自己的修改记录, 同步显示被修改的文件,关键字 --stat --author --abbrev-commit
git config --global alias.lms "log --no-merges --color --stat --author='knowledgebao' --date=format:'%Y-%m-%d %H:%M:%S' --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Cblue %s %Cgreen(%cd) %C(bold blue)<%an>%Creset' --abbrev-commit"

# 通过 git ls 查看所有的修改记录,关键字 --graph --abbrev-commit
git config --global alias.ls "log --no-merges --color --graph --date=format:'%Y-%m-%d %H:%M:%S' --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Cblue %s %Cgreen(%cd) %C(bold blue)<%an>%Creset' --abbrev-commit"

# 通过 git lss 查看所有的修改记录,同步显示被修改的文件,关键字 --stat --graph --abbrev-commit
git config --global alias.lss "log --no-merges --color --stat --graph --date=format:'%Y-%m-%d %H:%M:%S' --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Cblue %s %Cgreen(%cd) %C(bold blue)<%an>%Creset' --abbrev-commit"

# 通过 git ll  关键字 --first-parent
git config --global alias.ll "log --graph --oneline --abbrev-commit --decorate --first-parent --pretty='tformat:%ai %C(auto) %h %d %s %Cblue<%an %ar>'"

# 通过 git lg  关键字 --branches
git config --global alias.lg "log --graph --oneline --abbrev-commit --decorate --branches --pretty='format:%C(auto) %h %d %s %Cblue<%an %ar>'"

# 通过 git lga  关键字 --all
git config 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值