Last Updated: February 25, 2016
· smallhadroncollider

Use SublimeGit for quick frequent commits

TL;DR: Get SublimeGit and setup some alt+ keyboard shortcuts for a seamless Git workflow

Committing code to Git frequently is essential for properly tracking changes, but swapping between Sublime Text and the terminal to stage/commit files is enough of an inconvenience that I was finding myself spending an hour at the end of each day sorting through changes or, worse, doing useless mass commits.

I decided to look for a Git plugin for Sublime Text 3 and came across SublimeGit (a bargain at only €10). This plugin adds a plethora of Git commands to the Sublime Text command bar as well as an interactive staging tool. My favourite command is the Quick Commit File command which pops up an area to enter a commit message and then commits that file. It also has a Status panel that shows you all the changed files (with diffs if you click through).

By setting up some of the Git commands to alt+ keyboard shortcuts (I never find myself using 'é' or 'ü' in my code) you can make the git workflow seamless. Made a quick change to a file? alt+q, type in a commit message, and it's done. Made a changes to a few files? alt+a as you go along to stage files and then alt+c to commit them with a quick message.

Here's my shortcuts setup:

{ "keys": ["alt+q"], "command": "git_quick_commit_current_file" },
{ "keys": ["alt+c"], "command": "git_quick_commit" },
{ "keys": ["alt+b"], "command": "git_checkout_branch" },
{ "keys": ["alt+a"], "command": "git_add_current_file" },
{ "keys": ["alt+z"], "command": "git_checkout_current_file" },
{ "keys": ["alt+l"], "command": "git_log" },
{ "keys": ["alt+s"], "command": "git_quick_status" },
{ "keys": ["alt+d"], "command": "git_diff_cached" },
{ "keys": ["alt+u"], "command": "git_status" },
{ "keys": ["alt+p"], "command": "git_push" }

I happened to discover SublimeGit as I was rewriting a project from scratch that I'd started on the previous week. I went from 33 commits in one week to over 90 in the first day.

[Depending on your Git philosophy you may want to squash/rebase commits before pushing to a main repository (if there is one), but that will be much easier with proper commits to work from.]