Creating Git diff gists

A few weeks ago I asked you a very important question: How pretty are your Git diff’s?

Side note: I now realise that’s grammatically incorrect – shouldn’t have an apostrophe!

Anyway, using pretty-diff makes them pretty darn pretty.  But that’s not all that pretty-diff can do.

If you haven’t already, you need to install the tool like this…

npm install -g pretty-diff

Now the next step is to add your GitHub username to your global config, using the following command (or you can use a text editor)…

git config --global github.user "USERNAME"

You’ll also need to go to GitHub and create a Personal Access Token which has the “Create gist” permission, and then add this to your global config file as well…

git config --global gist-diff.token "TOKEN"

Now when you’ve made your changes and previewed them using pretty-diff, you can automatically create a Gist using this command…

gist-diff

This creates the Gist and opens the browser to show it, simple as that!  Sharing your code to get feedback on a potential change or enhancement has never been easier, especially when you’re unsure about your change or it’s not ready for a pull request yet.