git.sh 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. # Git Aliases (mostly mnemonic)
  2. alias ga.='git add -A .'
  3. alias ga='git add'
  4. alias gap='git add -p'
  5. alias gb='git branch'
  6. alias gba='git branch -a'
  7. alias gbav='git branch -av'
  8. alias gbd='git branch -D'
  9. alias gbv='git branch -v'
  10. alias gc='git commit -v'
  11. alias gco='git checkout'
  12. alias gcob='git checkout -b'
  13. alias gcop='git checkout -p'
  14. alias gd='git diff'
  15. alias gds='git diff --staged'
  16. alias gf='git fetch --all --tags && git fetch --all --prune'
  17. alias ggpush='git push -u origin $(__gitp_branch)'
  18. alias gm='git merge'
  19. alias gr='git reset'
  20. alias grh='git reset --hard'
  21. alias grhh='git reset HEAD --hard'
  22. alias grs='git reset --soft'
  23. alias grv='git remote -v'
  24. alias gs='git status'
  25. alias gsr='git show --format=raw' # all info about a commmit.
  26. # Git log (`gl`). Displays graph, decorations, users and dates.
  27. [[ $(version-compare $GIT_VER "1.8.3") -ge 0 ]] && DECO_COLOUR='%C(auto)' || DECO_COLOUR='%Cgreen'
  28. GL_PRETTY="'format:%C(yellow)%h %Creset%ad %Cblue%an:$DECO_COLOUR%d %Creset%s'"
  29. GL_OPTS="--graph --date=short --pretty=$GL_PRETTY"
  30. alias gl="git log $GL_OPTS"
  31. alias gla='gl --all' # show all refs, not only those reachable from current branch.
  32. alias glb='gl --simplify-by-decoration' # show mostly branches and tags.
  33. alias glh="git --no-pager log --max-count=15 $GL_OPTS" # show first few (head)
  34. alias glp='git log --graph --decorate -p'
  35. alias gls='git log --graph --decorate --stat'
  36. # Searching history.
  37. alias glG='git log --stat -G' # Search DIFFS - changes with given text.
  38. alias glS='git log --stat -S' # Search DIFFS - changes in number of given text.
  39. alias glg='git log --grep' # Search MESSAGES.
  40. # Submodule management.
  41. alias gsm='git submodule'
  42. alias gsmpull='git submodule foreach git pull origin master'
  43. alias gsmup='git submodule sync && git submodule update --init --recursive'
  44. # Fix tracking for origin if not there.
  45. alias track='git branch --set-upstream-to origin/$(__gitp_branch) && git fetch'
  46. # Autosquashing for simple fixups.
  47. alias grb='git rebase'
  48. alias grba='git rebase --abort'
  49. alias grbc='git rebase --continue'
  50. alias grbi='git rebase -i --autosquash'
  51. alias gcf='git commit --fixup'
  52. alias gcs='git commit --squash'
  53. # Create Work-In-Progress commits.
  54. alias gunwip='git log -n 1 | grep -q -c "\-\-wip\-\-" && git reset HEAD~1'
  55. alias gwip='git add -A; git rm $(git ls-files --deleted) 2>/dev/null; git commit -m "--wip--"'