Simplifying git Commands with Aliases
Whether 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:
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:
That looks more concise, doesn’t it? Less typing (and fewer typos). To create aliases for the above commands, the syntax is:
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!