Jake Worth

Jake Worth

mgrim: Everything Updated All The Time

Published: July 11, 2018 2 min read

  • git
  • terminal

My current favorite command line alias is mgrim, composed of four other aliases:

alias gmr='gco master && gpr && gco - && git rebase master'
alias grim='git rebase -i master'
alias mgrim='gmr && grim'

Here’s what this does (starting from a feature branch):

  • gmr - checkout the master branch (gco is a Hashrocket alias for git checkout. Pull from origin/master and try to put my commits in the right place in history (gpr is a Hashrocket alias for git pull --rebase). Checkout my feature branch. Fast-forward my branch to the top of master (as though I had branched off master’s current HEAD.
  • grim - Open an interactive rebase to cleanup everything on my branch (see ‘Squash Your PR’)

I use feature branches for work, and use this command right before merging into master. The result? I’m always forced to look at my branch history and squash it down to the minimum, which is good for everyone (including future me). And, I never have a merge conflict with master.

What are your thoughts on this? Let me know!


Join 100+ engineers who subscribe for advice, commentary, and technical deep-dives into the world of software.