oh-my-zsh中的 git 别名

oh-my-zsh中的 git 别名

oh my zsh 会自动启用 git 插件,默认有很多方便的别名,在此记录一下,可以使用下面的命令查看 git 插件具体替换了什么

cat ~/.oh-my-zsh/plugins/git/git.plugin.zsh

别名

别名原命令
grtcd "$(git rev-parse --show-toplevel \|\| echo .)"
ggpnpggl && ggp
ggpurggu
ggit
gagit add
gaagit add --all
gapagit add --patch
gaugit add --update
gavgit add --verbose
gwipgit add -A; git rm $(git ls-files --deleted) 2> /dev/null; git commit --no-verify --no-gpg-sign --message "--wip-- [skip ci]"
gamgit am
gamagit am --abort
gamcgit am --continue
gamscpgit am --show-current-patch
gamsgit am --skip
gapgit apply
gaptgit apply --3way
gbsgit bisect
gbsbgit bisect bad
gbsggit bisect good
gbsngit bisect new
gbsogit bisect old
gbsrgit bisect reset
gbssgit bisect start
gblgit blame -w
gbgit branch
gbagit branch --all
gbdgit branch --delete
gbDgit branch --delete --force
gbgdLANG=C git branch --no-color -vv \| grep ": gone\]" \| cut -c 3- \| awk '"'"'{print $1}'"'"' \| xargs git branch -d
gbgDLANG=C git branch --no-color -vv \| grep ": gone\]" \| cut -c 3- \| awk '"'"'{print $1}'"'"' \| xargs git branch -D
gbmgit branch --move
gbnmgit branch --no-merged
gbrgit branch --remote
ggsupgit branch --set-upstream-to=origin/$(git_current_branch)
gbgLANG=C git branch -vv \| grep ": gone\]"
gcogit checkout
gcorgit checkout --recurse-submodules
gcbgit checkout -b
gcBgit checkout -B
gcdgit checkout $(git_develop_branch)
gcmgit checkout $(git_main_branch)
gcpgit cherry-pick
gcpagit cherry-pick --abort
gcpcgit cherry-pick --continue
gcleangit clean --interactive -d
gclgit clone --recurse-submodules
gccdgit clone --recurse-submodules "$@" && cd "$(basename $\_ .git)"
gcamgit commit --all --message
gcasgit commit --all --signoff
gcasmgit commit --all --signoff --message
gcmsggit commit --message
gcsmgit commit --signoff --message
gcgit commit --verbose
gcagit commit --verbose --all
gca!git commit --verbose --all --amend
gcan!git commit --verbose --all --no-edit --amend
gcans!git commit --verbose --all --signoff --no-edit --amend
gcann!git commit --verbose --all --date=now --no-edit --amend
gc!git commit --verbose --amend
gcn!git commit --verbose --no-edit --amend
gcsgit commit -S
gcssgit commit -S -s
gcssmgit commit -S -s -m
gcfgit config --list
gdctgit describe --tags $(git rev-list --tags --max-count=1)
gdgit diff
gdcagit diff --cached
gdcwgit diff --cached --word-diff
gdsgit diff --staged
gdwgit diff --word-diff
gdvgit diff -w "$@" \| view -
gdupgit diff @{upstream}
gdnolockgit diff $@ ":(exclude)package-lock.json" ":(exclude)\*.lock"
gdtgit diff-tree --no-commit-id --name-only -r
gfgit fetch
gfagit fetch --all --prune
gfogit fetch origin
gggit gui citool
ggagit gui citool --amend
ghhgit help
glgggit log --graph
glggagit log --graph --decorate --all
glgmgit log --graph --max-count=10
glodgit log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ad) %C(bold blue)<%an>%Creset'
glodsgit log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ad) %C(bold blue)<%an>%Creset' --date=short
glolgit log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ar) %C(bold blue)<%an>%Creset'
glolagit log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ar) %C(bold blue)<%an>%Creset' --all
glolsgit log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ar) %C(bold blue)<%an>%Creset' --stat
glogit log --oneline --decorate
gloggit log --oneline --decorate --graph
glogagit log --oneline --decorate --graph --all
glpgit log --pretty=<format>
glggit log --stat
glgpgit log --stat --patch
gignoredgit ls-files -v \| grep "^[[:lower:]]"
gfggit ls-files \| grep
gmgit merge
gmagit merge --abort
gmcgit merge --continue
gmsgit merge --squash
gmomgit merge origin/$(git_main_branch)
gmumgit merge upstream/$(git_main_branch)
gmtlgit mergetool --no-prompt
gmtlvimgit mergetool --no-prompt --tool=vimdiff
glgit pull
gprgit pull --rebase
gprvgit pull --rebase -v
gpragit pull --rebase --autostash
gpravgit pull --rebase --autostash -v
gpromgit pull --rebase origin $(git_main_branch)
gpromigit pull --rebase=interactive origin $(git_main_branch)
ggpullgit pull origin "$(git_current_branch)"
gglgit pull origin $(current_branch)
glucgit pull upstream $(git_current_branch)
glumgit pull upstream $(git_main_branch)
gpgit push
gpdgit push --dry-run
gpf!git push --force
ggfgit push --force origin $(current_branch)
gpfOn Git >= 2.30: git push --force-with-lease --force-if-includes
gpfOn Git < 2.30: git push --force-with-lease
ggflgit push --force-with-lease origin $(current_branch)
gpsupgit push --set-upstream origin $(git_current_branch)
gpsupfOn Git >= 2.30: git push --set-upstream origin $(git_current_branch) --force-with-lease --force-if-includes
gpsupfOn Git < 2.30: git push --set-upstream origin $(git_current_branch) --force-with-lease
gpvgit push --verbose
gpoatgit push origin --all && git push origin --tags
gpodgit push origin --delete
ggpushgit push origin "$(git_current_branch)"
ggpgit push origin $(current_branch)
gpugit push upstream
grbgit rebase
grbagit rebase --abort
grbcgit rebase --continue
grbigit rebase --interactive
grbogit rebase --onto
grbsgit rebase --skip
grbdgit rebase $(git_develop_branch)
grbmgit rebase $(git_main_branch)
grbomgit rebase origin/$(git_main_branch)
grfgit reflog
grgit remote
grvgit remote --verbose
gragit remote add
grrmgit remote remove
grmvgit remote rename
grsetgit remote set-url
grupgit remote update
grhgit reset
grugit reset --
grhhgit reset --hard
grhkgit reset --keep
grhsgit reset --soft
gpristinegit reset --hard && git clean --force -dfx
gwipegit reset --hard && git clean --force -df
grohgit reset origin/$(git_current_branch) --hard
grsgit restore
grssgit restore --source
grstgit restore --staged
gunwipgit rev-list --max-count=1 --format="%s" HEAD \| grep -q "--wip--" && git reset HEAD~1
grevgit revert
grmgit rm
grmcgit rm --cached
gcountgit shortlog --summary -n
gshgit show
gspsgit show --pretty=short --show-signature
gstallgit stash --all
gstugit stash --include-untracked
gstaagit stash apply
gstcgit stash clear
gstdgit stash drop
gstlgit stash list
gstpgit stash pop
gstaOn Git >= 2.13: git stash push
gstaOn Git < 2.13: git stash save
gstsgit stash show --patch
gstgit status
gssgit status --short
gsbgit status --short -b
gsigit submodule init
gsugit submodule update
gsdgit svn dcommit
git-svn-dcommit-pushgit svn dcommit && git push github $(git_main_branch):svntrunk
gsrgit svn rebase
gswgit switch
gswcgit switch -c
gswdgit switch $(git_develop_branch)
gswmgit switch $(git_main_branch)
gtagit tag --annotate
gtsgit tag -s
gtvgit tag \| sort -V
gignoregit update-index --assume-unchanged
gunignoregit update-index --no-assume-unchanged
gwchgit whatchanged -p --abbrev-commit --pretty=medium
gwtgit worktree
gwtlsgit worktree list
gwtmvgit worktree move
gwtrmgit worktree remove
gkgitk --all --branches &!
gkegitk --all $(git log --walk-reflogs --pretty=%h) &!
gtlgtl(){ git tag --sort=-v:refname -n --list ${1}\* }; noglob gtl

主分支偏好

继最近推动从我们的技术词汇中删除带有种族色彩的词汇之后,git 插件

倾向于使用 "master "以外的分支名称。在这种情况下,我们倾向于使用更简短、中性和描述性的

主"。这意味着以前使用过 master 的别名和函数将使用 main

分支。我们通过函数 git_main_branch 来实现这一点。

已弃用的别名

这些别名已被删除、重命名或以其他方式修改,修改方式可能与 获得进一步的支持。

别名原命令修改后
gapgit add --patchNew alias: gapa.
gclgit config --listNew alias: gcf.
gdcgit diff --cachedNew alias: gdca.
gdtgit difftoolNo replacement.
ggpullgit pull origin $(current_branch)New alias: ggl. (ggpull still exists for now though.)
ggpurgit pull --rebase origin $(current_branch)New alias: ggu. (ggpur still exists for now though.)
ggpushgit push origin $(current_branch)New alias: ggp. (ggpush still exists for now though.)
gkgitk --all --branchesNow aliased to gitk --all --branches.
glggit log --stat --max-count=10Now aliased to git log --stat --color.
glgggit log --graph --max-count=10Now aliased to git log --graph --color.
gwcgit whatchanged -p --abbrev-commit --pretty = mediumNew alias: gwch.
gupgit pull --rebasenow alias gpr
gupvgit pull --rebase -vnow alias gprv
gupagit pull --rebase --autostashnow alias gpra
gupavgit pull --rebase --autostash -vnow alias gprav
gupomgit pull --rebase origin $(git_main_branch)now alias gprom
gupomigit pull --rebase=interactive origin $(git_main_branch)now alias gpromi

功能

当前

命令描述
current_branchReturns the name of the current branch.
git_current_user_emailReturns the user.email config value. (Lives in lib/git.zsh.)
git_current_user_nameReturns the user.name config value. (Lives in lib/git.zsh.)
git_develop_branchReturns the name of the “development” branch: dev, devel, development if they exist, develop otherwise.
git_main_branchReturns the name of the main branch: main if it exists, master otherwise.
grename <old> <new>Renames branch <old> to <new>, including on the origin remote.
gbdaDeletes all merged branches
gbdsDeletes all squash-merged branches (Note: performance degrades with number of branches)

正在进行的工作(WIP)

这些功能允许您暂停开发一个分支并切换到另一个分支(“正在进行的工作”,或 “wip”)。当您想要返回工作时,只需“unwip”即可。

命令描述
gwipCommit wip branch
gunwipUncommit wip branch
gunwipallUncommit all recent --wip-- commits
work_in_progressEchoes a warning if the current branch is a wip

请注意,gwipgunwip 是别名,但也记录在此,以便对所有相关的 WIP 功能进行分组。

已弃用的函数

命令描述原因
current_repositoryReturn the names of the current remotesDidn't work properly. Use git remote -v instead (grv alias).
  • Loading...
  • Loading...
  • Loading...
  • Loading...
  • Loading...