Configuring Git for high productivity coding

Git is a powerful version control system which is used extensively here at Amazon. We use it to version our Python, C# and Java code as well as other scripts. The good thing about Git is that it is highly configurable with aliases and hooks.

Aliases allow you to create a shortcut of a very long command using a shorter command. For example, if you want to do a ‘git log’ with extra parameters which change how it is displayed then you can make an alias for that command with a shorter command. In my gitconfig file I’ve got a bunch of common aliases plus some personal ones that I’ve come up with in order to save time. Read this guide for setting up git.

Another way of configuring git is by using the hooks feature. Hooks are scripts that are run when certain git commands are run. The ‘pre-commit’ hook is run to check certain things about what you’re commiting and it can even return messages to you if you’ve forgotten something. Another very common hook is the ‘post-commit’ hook which can be used for sending out emails or Slack notifications upon a successful commit.

At Amazon we use a bunch of these hooks for things such as collecting metrics and triggering unit tests to run. Hooks are also the basis of continuous integration systems such as Jenkins and Gerrit but those are beyond the scope of this post.

Sure there are some areas of the company that still use Subversion or another subpar VCS but Git is clearly the winner at this organization and most teams use git very effectively. I would recommend that you learn how to configure your environment with git aliases and hooks to make your workflow more smooth.

Advertisements
Configuring Git for high productivity coding

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s