02/18/2015 - No Comments!

Git Shortcuts

GitShort

This is one of those subject where you wonder how it took you so long to figure out. Am I the last one to learn this? Probably. But in the off chance there are still a few suckers out there using full length git commands, not personalized shortcuts, this is for you.


Git Shortcuts, FTW!

As the title subtly suggests, git allows the use of configurable shortcuts for your more common commands. Never misspell a git status again! Joy. Here is the basic setup for this in your local environment:

  1. Run git config in a project using git to open up the configuration file.
  2. The syntax is as follows $ git config --global alias.gst status
    • Adding this line in my config file will now store the alias gst to mean status.
    • I can now run gst in the command line and it reads as git status.
  3. That's it.

Some other common shortcuts may include:

 $ git config --global alias.co checkout
 $ git config --global alias.br branch
 $ git config --global alias.ci commit
 $ git config --global alias.st status

But it really depends on your personal workflow and the task(s) at hand. You can also link commands together to make up your own, but I haven't played around with this personally too much as of yet.

To google around the web for more information on this, try Git Aliases as it's more commonly referred to. Enjoy those saved keystrokes!

Further Resources

  • http://githowto.com/aliases
  • http://git-scm.com/book/en/v1/Git-Basics-Tips-and-Tricks
  • https://jonsuh.com/blog/git-command-line-shortcuts/

Published by: Ray in Learning