美文网首页
ZSH中的git快捷键

ZSH中的git快捷键

作者: lxyz22zp | 来源:发表于2018-03-27 14:19 被阅读1221次

    git

    alias g='git'
    

    git fetch

    alias gf='git fetch'
    alias gfa='git fetch --all --prune'
    alias gfo='git fetch origin'
    

    git pull

    # git pull –rebase 这样的结局就完全不一样。—rebase 并不会产生一个commit提交,详见 https://www.cnblogs.com/wangiqngpei557/p/6056624.html
    # git pull --rebase = git fetch + git rebase
    alias gup='git pull --rebase'
    alias gupv='git pull --rebase -v'
    alias glum='git pull upstream master'
    

    git status

    #显示当前目录下文件的状态,红色的问号表示git不知道这份文件是什么,需要add,绿色的A表示add的缩写。M表示有修改的文件
    alias gsb='git status -sb'
    alias gsd='git svn dcommit'
    alias gsi='git submodule init'
    alias gsps='git show --pretty=short --show-signature'
    alias gsr='git svn rebase'
    alias gss='git status -s'
    alias gst='git status'
    alias gsu='git submodule update'
    

    git add

    alias ga='git add'
    alias gaa='git add --all'
    alias gapa='git add --patch'
    alias gau='git add --update'
    alias gap='git apply'
    

    git stash

    alias gsta='git stash save'
    alias gstaa='git stash apply'
    alias gstc='git stash clear'
    alias gstd='git stash drop'
    alias gstl='git stash list'
    alias gstp='git stash pop'
    alias gsts='git stash show --text'
    

    git reset

    # 将某个已经暂存的文件取消暂存
    alias grh='git reset HEAD'
    
    # 虽然在调用时加上 --hard 选项可以令 git reset 成为一个危险的命令(译注:可能导致工作目录中所有当前进度丢失!),但本例中工作目录内的文件并不会被修改。 不加选项地调用 git reset 并不危险 — 它只会修改暂存区域。
    alias grhh='git reset HEAD --hard'
    alias gru='git reset --'
    
    

    git commit

    alias gc='git commit -v'
    alias gc!='git commit -v --amend'
    alias gcn!='git commit -v --no-edit --amend'
    alias gca='git commit -v -a'
    alias gca!='git commit -v -a --amend'
    alias gcan!='git commit -v -a --no-edit --amend'
    alias gcans!='git commit -v -a -s --no-edit --amend'
    alias gcam='git commit -a -m'
    alias gcsm='git commit -s -m'
    

    git push

    alias gp='git push'
    alias gpd='git push --dry-run'
    alias gpoat='git push origin --all && git push origin --tags'
    compdef _git gpoat=git-push
    alias gpu='git push upstream'
    alias gpv='git push -v'
    

    git log

    alias gl='git pull'
    alias glg='git log --stat'
    alias glgp='git log --stat -p'
    alias glgg='git log --graph'
    alias glgga='git log --graph --decorate --all'
    alias glgm='git log --graph --max-count=10'
    alias glo='git log --oneline --decorate'
    alias glol="git log --graph --pretty='%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit"
    alias glola="git log --graph --pretty='%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --all"
    alias glog='git log --oneline --decorate --graph'
    # 它会输出你的提交历史、各个分支的指向以及项目的分支分叉情况。
    alias gloga='git log --oneline --decorate --graph --all'
    

    git branch

    alias gb='git branch'
    alias gba='git branch -a'
    alias gbd='git branch -d'
    alias gbda='git branch --no-color --merged | command grep -vE "^(\*|\s*(master|develop|dev)\s*$)" | command xargs -n 1 git branch -d'
    alias gbl='git blame -b -w'
    alias gbnm='git branch --no-merged'
    alias gbr='git branch --remote'
    

    git merge

    alias gm='git merge'
    alias gmom='git merge origin/master'
    alias gmt='git mergetool --no-prompt'
    alias gmtvim='git mergetool --no-prompt --tool=vimdiff'
    alias gmum='git merge upstream/master'
    alias gma='git merge --abort'
    

    git rebase

    alias grb='git rebase'
    alias grba='git rebase --abort'
    alias grbc='git rebase --continue'
    alias grbi='git rebase -i'
    alias grbm='git rebase master'
    alias grbs='git rebase --skip'
    

    git checkout

    alias gcb='git checkout -b'
    alias gcf='git config --list'
    alias gcl='git clone --recursive'
    alias gclean='git clean -fd'
    alias gpristine='git reset --hard && git clean -dfx'
    alias gcm='git checkout master'
    alias gcd='git checkout develop'
    alias gcmsg='git commit -m'
    alias gco='git checkout'
    alias gcount='git shortlog -sn'
    compdef _git gcount
    alias gcp='git cherry-pick'
    alias gcpa='git cherry-pick --abort'
    alias gcpc='git cherry-pick --continue'
    alias gcs='git commit -S'
    

    git diff

    alias gd='git diff'
    alias gdca='git diff --cached'
    alias gdcw='git diff --cached --word-diff'
    alias gdct='git describe --tags `git rev-list --tags --max-count=1`'
    alias gdt='git diff-tree --no-commit-id --name-only -r'
    alias gdw='git diff --word-diff'
    

    git bisect

    alias gbs='git bisect'
    alias gbsb='git bisect bad'
    alias gbsg='git bisect good'
    alias gbsr='git bisect reset'
    alias gbss='git bisect start'
    

    git gui citoo

    alias gg='git gui citool'
    alias gga='git gui citool --amend'
    

    git remote

    # git remote add <shortname> <url> 添加一个新的远程 Git 仓库,同时指定一个你可以轻松引用的简写:
    alias gra='git remote add'
    alias grmv='git remote rename'
    alias grrm='git remote remove'
    alias grset='git remote set-url'
    alias grt='cd $(git rev-parse --show-toplevel || echo ".")'
    alias grup='git remote update'
    alias grv='git remote -v'
    

    git tag

    alias gts='git tag -s'
    alias gtv='git tag | sort -V'
    

    alias gunignore='git update-index --no-assume-unchanged'
    alias gunwip='git log -n 1 | grep -q -c "\-\-wip\-\-" && git reset HEAD~1'
    
    alias gwch='git whatchanged -p --abbrev-commit --pretty=medium'
    alias gwip='git add -A; git rm $(git ls-files --deleted) 2> /dev/null; git commit --no-verify -m "--wip-- [skip ci]"'
    
    

    相关文章

      网友评论

          本文标题:ZSH中的git快捷键

          本文链接:https://www.haomeiwen.com/subject/duzjcftx.html