git.zsh 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. # preferred git shortcuts, not in the git plugin
  2. alias ga.='git add .'
  3. alias gap='git add -p'
  4. alias gs='git status'
  5. alias gd='git diff'
  6. alias gds='git diff --staged'
  7. alias gcob='git checkout -b'
  8. alias gf='git fetch --tags && git fetch --prune'
  9. alias gbd='git branch -D'
  10. # standard log with train tracks
  11. alias gl='git log --graph --pretty="format:%C(yellow)%h%Cgreen%d %Cblue[%an] %Creset%s... %C(cyan)%ar%Creset"'
  12. # concise, branch and tag log with train tracks (some merge commits unavoidable)
  13. alias glb='gl --simplify-by-decoration'
  14. alias glp='git log --patch'
  15. # useful when you want to have a visual on file changes
  16. alias gls='git log --graph --stat'
  17. # search through history for particular text
  18. alias glS='git log -S'
  19. alias gr='git reset'
  20. alias grh='git reset --hard'
  21. alias grs='git reset --soft'
  22. alias grb='git rebase'
  23. # useful for finding parent commit for a given commit hash
  24. alias gsr='git show --format=raw'
  25. # git submodule management
  26. alias gsm='git submodule'
  27. alias gsmup='git submodule sync && git submodule update --init'
  28. alias gsmpull='git submodule foreach git pull origin master'
  29. # useful if you forget to setup tracking for a new branch when checking out.
  30. alias track='git branch --set-upstream $(current_branch) origin/$(current_branch) && git fetch'
  31. # useful omz git plugin ones include:
  32. # ga, gc, gco, gb, gba, gm, grhh, ggpull, ggpush
  33. #
  34. # ggpull translates into `git pull origin <current branch>`, same for ggpush
  35. #
  36. # Note: both the gg's are extremely convenient! And safe, because you never know
  37. # if tracking has been setup properly on a branch.