Adding `git squash` to my git workflow

This post was originally a TweetStorm. Read that tweetstorm.

This post is part of a group I’ve written about improving your version control skills.

I’m pretty sure that squashing commits is now going to be a part of my git workflow. I’ve had some serious level ups in my git workflow as I’ve continued working as a developer. This is definitely one of them.

The habit of regular small (even trivial) commits, was baked into me while going through Dev Bootcamp in Chicago with regular commit intervals on the half hour. I further cemented this by including a tool in my terminal prompt that told me the time since my last commit on my current branch, similar to what @Goles has written here for the Zsh terminal.

picture credit to Tuo Huang from this post

Eventually I learned of git commit patch and Gitx. I previously wrote about git committing interactively.

Some folks told me I was potentially making my commits too small! This is were git squash -ing becomes so useful.

With git squash in your VCS toolbelt it doesn’t matter that I wrote 1 commit every 30 minutes. Or turned an hour’s worth of work into 4 commits. Sometimes that story needs to be editing, which is where git squash comes in.

Now after my full git log of commits I can go back and edit.

git commit drunk, git squash sober

Git squash allows you to turn the three commits into one for that test you wrote. Or to turn the passing test and the correctly method into one single commit.

Allows you to totally remove an unused piece of git history, like the comment you added asking a question, which was then answered within the code review process on your great pull request.

Allows you to amend the first and second and third of a 30 commit git branch not just the last commit.

You can turn your Hobbit trilogy into the one movie it should’ve been, without that non-canon love triangle.

Now you might be asked to do this when contributing to Open Source Software or just opening a pull request against your team’s branch or repo.

Git squashing also pairs well with git cherry-picking. They are are similar, yet different skills. So check out git squashing and add it to your repertoire of git skills.

Additional Resources

  1. Github : @goles zsh_git_timer

  2. Git tip: show current branch and time elapsed since last commit in command line by Tuo Huang

If you enjoyed this post, please subscribe to my newsletter

On why you should learn Emacs or Vim, as soon as you're comfortable with your first editor

AKA: How I learned to stop worrying and love Emacs, which is the bomb!

This post was originally a TweetStorm. You can see that Tweetstorm storified here

The Journey Awaits

You’re a newbie programmer. We all were once! You’re teaching yourself using one of the recommended programming learning platforms. I wrote about learning within Programming Platforms in my post titled, Thoughts on learning as a junior dev.

It feels like the time to enter the wild world of non-platform based coding environments. Starting a long loving relationship between your favorite Text Editor and You. You tackle a few tutorials.

Cat in Pink Wig Typing

This is great!
{Sublime Text||Atom||Brackets} is awesome.
Look at this slick new theme I’ve got, all these dope packages I’ve installed. I’m templating with Emmett. Linting like crazy.

You’ve got this covered. You feel at home in your text editor.

Now is the time to give your new friendly neighborhood in terminal editor a chance.

The Battle Begins

I’m not going to get into the battle of Vim versus Emacs. Let someone else fight that war. It’ll be better than Batman v. Superman at least.

So just choose one. How? Probably the one a peer is using and will happily teach you the way in.

Rey is the Sh*t

It’ll be a humbling start. You won’t know how to navigate or select things. The thing is…. There’s not really a cursor, no mouse. You’re stuck on the keyboard.

But don’t fret you’re going to level up.

You’ll go from not knowing how to quit the text editor

You quit Vim with :q, You quit Emacs with the not-included foot pedal and midi-keyboard

To being a keyboard wiz

And this kids is what your brain is like on Tmux

The Force Awakens

The reasons you’ll benefit from working with Vim or Emacs are as follows:

You probably didn’t know how badly that mouse & trackpad were holding you back. You should spend as much time on the keyboard as possible. It’ll become oh so evident how much you rely on them. You’ll see your shortcomings first hand.

There’s a pretty high learning curve. This probably isn’t an accurate description, but it’s worth considering.

Emacs: Upwards, not forward and always twirling, twirling, twirling towards freedom!

As you progress in learning your chosen editor you’ll start to notice where the navigation and keyboard skills you’ve picked up can be applied elsewhere. It’s fun to discover the numerous places where you can navigate with the ctrl+N,ctrl+P,ctrl+F, ctrl+B movement keys present in Emacs or the h,j,k,l movement keys in Vim.

You’ll get more intimately acquainted with your terminal. Rather than giving half your attention to your text editor and half to your terminal, all of your focus rests inside the terminal. Do you need to ssh into a box without a nice GUI? Sure no problem! Let’s open Vim or Emacs in the box and go at it.

Once the basics are embedded into your head, you’ll slowly gather speed. Now that you’re spending more time hands on keyboard, not on the track pad or mouse, your overall productivity has gone up.

Remember all those handy packages you were using. That sweet as theme. Those are available for Vim and Emacs. Slowly but surely you’ll add packages and tools back into your upgraded utility belt.

Then when you feel you’re comfortable with Vim or Emacs, the choice is up to you. At that point you can go back to your old text editor with these new found super powers. I’ve recently done this, returning to Atom. Stay with Vim or Emacs. Maybe you make the choice to move to another IDE like Eclipse, RubyMine, Webstorm, or IntelliJ. It’s about choosing the right tool for the project, for you, and for your workflow.

Why you should learn Vim or Emacs now - Machete Order

To recap, by diving into using Vim or Emacs early on, you’ll overcome that learning curve faster. No fear. I've made a terrible mistake

Do so for the following reasons:

  • Overall productivity increase as you won’t rely on the mouse or trackpad

  • Greater familiarity with your terminal

  • Portability of this knowledge to most any system (most have vim or emacs)

  • The capacity to use shortcuts or navigation from Emacs or Vim elsewhere

  • Knowing you’ve conquered one of those “good to have” Dev experiences and moving forward however you please

Go give one of them a try today.

Addendum: The Vim & Emacs Christmas Special - Tips & Tricks!

  1. Vim and Emacs have cool online and in-text editor tutorials.
    • Emacs has a tutorial within the text editor itself, you can access it by using the following hotkeys ctrl+h, t
    • Vim has a fun online tutorial called Vim Adventures
  2. Make your desktop background a cheatsheet of shortcuts and commands for your chosen editor to refer back to and learn
  3. Keep researching different commands with the help of your peers and the Internet.

  4. Disable your arrow keys when using either terminal (enable hard mode)

Classes in HTML & CSS (screencast)

This screencast talks about Classes and how we use them in HTML and CSS