Git Tip: My Favorite Git Aliases

Git aliases that make my life easier. I don’t like needing to remember long terminal commands.

[alias]
  # save some key strokes
  co = checkout
  cp = cherry-pick

  # remove branches that are not present in remote
  klean = !git branch -vv | grep ': gone]' | awk '{print $1}' | xargs git branch -d

  # remove branches that are not present in remote even if they have not been merged into master
  kleanD = !git branch -vv | grep ': gone]' | awk '{print $1}' | xargs git branch -D

  # pull and push - if you commit on a branch and can't push because the remote is ahead, this will do the pull and push
  pap = !git pull --rebase && git push

  # fetch remote, prune, and pull in one command
  update = !git fetch --all --prune && git pull --rebase

  # update misspell
  udpate = !git fetch --all --prune && git pull --rebase