Review a PR then get back to work … faster!

I never mind reviewing PRs from my coworkers, but I do want to minimize interruptions knowing I typically have other tasks in-flight. To help make the overhead of switching contexts (and branches) more efficient, try using the git pr command found in https://github.com/tj/git-extras …

I never mind reviewing PRs from my coworkers, but I do want to minimize interruptions knowing I typically have other tasks in-flight.  To help make the overhead of switching contexts (and branches) more efficient, try using the git pr  command found in https://github.com/tj/git-extras!

You’ll probably want to install git-extras before you continue with this post.  (It’s super quick and easy using Homebrew, as described below.)

Installation

For most Mac users, this is all you need:

Note: Installing from Homebrew will not give you the option omit certain git-extras  if they conflict with existing git aliases. To have this option, build from source.

Show me how!

Let’s say you’re chugging along on your own feature branch and you’ve reached a stopping point where you can safely switch contexts and help keep your team’s PRs from piling up …

  1. Commit or stash your changes.  You don’t want to lose any work, and trying to checkout another branch will result in an error, so finish up what you’re doing and commit/stash first.  Also, you might consider that if you’re not ready to commit the code changes you’ve made, you might not be cognitively ready to switch contexts anyway  🤓
  2. Pull the PR down for review.  Just run $ git pr 123  from within your existing working directory, replacing 123  with the appropriate PR number, or even the full URL to the PR.If you’re working from a fork, you can also specify a different remote, e.g., $ git pr 123 upstream .  (See the git pr docs for more information.)  Doing so will automatically checkout the 123 branch as pr/123 .Bonus!  If no new packages have been added/updated in package.json, you might not even need to restart your web server when checking out other branches. (Lingua changes may still require a restart, however.)
  3. Do your review thang.  Bring the site up, test it thoroughly, leave good feedback on GitHub … (you know the drill)
  4. Switch back to your branch.  You’ll need to switch back to your own feature branch before cleaning up the PR branch you pulled down.
  5. Clean it up.  Run $ git pr clean  to delete the PR branch and continue with your own feature work.

You should now be back in your own lane after helping to get your team’s commits reviewed and merged, having a strong sense of pride and accomplishment, and a minimum amount of time spent.

Further reading

Check out the entire list of commands and aliases added by git-extras, or check out this Vimeo screencast on some of the more popular git-extras commands.