Andrew Scripts

Musings about Programming and Programmer Life-Skills

Category: Git

My Favorite Git Aliases, Functions, and Configs

You can find all of these aliases and functions (and then some!) on my Github here: Read on for detailed explanations of what they are and what they do, and be sure to also check out my preferred git workflow.

Read the rest of this entry »


My One-Way Git Workflow (or, How to Git Well)

There are a lot of git workflows out there. This is mine, based on working with Git for 10-something years now. It makes use of git rebase, so turn away now if you’re scared of rebasing (and then go read this and realize it’s just another tool). BONUS: be sure to check out my handy git helpers too!

Read the rest of this entry »

Smarter-Git: My Rakefile of Automated Awesomeness

Smarter Git

I created this rakefile of git tasks back when I was working with a dev team that relied heavily on rake. My reasoning was that since I was already doing rake deploy:staging and the like all the time (they preferred Screwcap to Capistrano), I might as well do rake git:merge_and_deploy too. This works especially well with a text expander or bash alias, where you can setup rg: to expand to rake git: or rug: to become rake username:git: if you want to further namespace out these functions.

The tools I use here also work well by themselves or in their own aliases. Use this collection as a starting point for further customizing your workflow, or use as is for a quick but complete solution.

Here are the libraries I used in this rakefile:

  • Legit – Provides a handy ‘sprout’ function for new branch creation
  • Git Smart – Provides smart-merge, smart-pull, and smart-log
  • Git Extras

Awesome Git helpers: Git-Smart, Legit, Extras, etc.

Links to some amazing Git helpers and things.

Git-Smart and Legit have good install instructions. Here’s how to install the other scripts (which are all just shell scripts compatible with bash, zsh, probably others):

  1. Copy the raw script into a file, and put that file in a folder that’s in your $PATH (I use /usr/local/bin).
  2. Restart your terminal or source your .bashrc file.
  3. Profit! (Or, at least, enjoy your new scripts)

Git Extras and Git Utils can both be installed using Brew as well:

brew install git-extras git-utils

See changes between commits in Git

Github has an awesome feature that allows you to see a visual diff log of all of the changes between two commits. Learned how to do it on the command line today.

Here’s how to see the changes you’ve made in your repo between two commits (from the official Git docs):


Technically, you can use this to compare branches and tags too. Here’s a handy shortcut for comparing your most recent commit with the commit right before it:

git diff HEAD^ HEAD

Especially handy if, like me, you forgot what you just finished working on (or, more likely, if you haven’t worked on something for a couple days/weeks).

%d bloggers like this: