From b203fb309eca38e187944b60423c79156e54623c Mon Sep 17 00:00:00 2001 From: chenyc Date: Wed, 14 Dec 2022 16:10:32 +0800 Subject: [PATCH] update git config --- README.md | 22 ++++++++++++++++++++++ config/git.zsh | 10 ++++++++-- 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index b5da2bb..b0f3b2c 100644 --- a/README.md +++ b/README.md @@ -94,6 +94,28 @@ _OMZ_APPLY_CHPWD_HOOK 5. fzf-tab > tab时使用fzf进行候选选择 +6. 常用git命令支持(非插件) + > `gco` = `git checkout` + > `gpo` = `git push origin <当前分支>` + > `gpl` = `git pull origin <当前分支>` + > `gd` = `git diff` + > `gs` = `git status` + > `gss` = `更简洁的 git status` + > `gam` = `git add all 并 git commit -m '内容'`, e.g. `git commit update readme` + > `gll` = `简洁打印 git log`, 默认展示10条 若想展示更多 `gll 100` + > `glll` = `详细打印 git log`, 默认展示10条 若想展示更多 `glll 100` + >> 展示 glll效果如下 PS: 实际使用带颜色 可自行根据 [此文件:git.zsh](https://github.com/yaocccc/omz/blob/master/config/git.zsh) 内容配置对应颜色 + >> + >> $ glll + >> \* e797da3 2022-12-14 15:18 user1: fix: 透传减轻下游负载 + >> \* ed8a8ba 2022-12-14 14:41 user1: fix: 查询时透传id + >> \* 7c2799b 2022-12-13 19:04 user1: Merge branch 'abc' into 'master' + >> |\ + >> | * 3f2441b 2022-12-13 19:01 user1: fix: 修复安全隐患 + >> |/ + >> \* 70a46da 2022-12-13 18:27 user2: Merge branch 'fix/abcd' into 'master' + + ## FILE TREE ```plaintext diff --git a/config/git.zsh b/config/git.zsh index f60bd06..114ff64 100644 --- a/config/git.zsh +++ b/config/git.zsh @@ -1,5 +1,11 @@ export GIT_TERMINAL_PROMPT=1 +# 可配置以下环境变量控制git log颜色 +hashColor=${gitHashColor:-"magenta"} +contentColor=${gitContentColor:-"cyan"} +dateColor=${gitDateColor:-"yellow"} +authorColor=${gitAuthorColor:-"blue"} + alias gco='git checkout' alias gpo='git push origin $(git symbolic-ref --short -q HEAD)' alias gpl='git pull origin $(git symbolic-ref --short -q HEAD) --ff-only' @@ -13,5 +19,5 @@ gam() { git add --all && git commit -m "$*" } gitlog() { git --no-pager log --date=format:'%Y-%m-%d %H:%M' --pretty=format:$1 --graph -n ${2-10} \ } -gll() { gitlog "%C(magenta)%h %C(cyan)%s%Creset" $1 } -glll() { gitlog "%C(magenta)%h %C(yellow)%cd %Cblue%cn: %C(cyan)%s%Creset" $1 } +gll() { gitlog "%C(${hashColor})%h %C(${contentColor})%s%Creset" $1 } +glll() { gitlog "%C(${hashColor})%h %C(${dateColor})%cd %C(${authorColor})%cn: %C(${contentColor})%s%Creset" $1 }