Simplifying git Commands with Aliases

Rick HerrmannWhether you are a git beginner, or an experienced user that is comfortable with more advanced commands, there are a few basic commands that you will find yourself typing over and over again.  In my experience the most often used git functions are: status, checkout, commit, and branch.  Here’s an example:

blog1.jpg

To help save keystrokes and avoid re-typing the full command name, git allows you to create custom commands that alias the built in functions.  So instead of typing the commands above, you could instead type:

blog2.jpg

That looks more concise, doesn’t it?  Less typing (and fewer typos). To create aliases for the above commands, the syntax is:

blog3.jpg
These are the alias names I like to use, but you can use whatever makes sense for you, and other commands can be aliased as well. (Using –global applies the alias to all of the repositories on the machine, otherwise it will only apply to the current repository).

I usually don’t use shortcuts for things until I have felt some of the pain of NOT using them.  So, if you are brand new to git – I recommend you first take some time to get comfortable with the actual commands before aliasing them.  However, I think you’ll find that using aliases is a simple way to make git easier to use.

 

Learn more about the “Chronicles of Nerdia” IBS Microsoft Technology Group!

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