Pair program with me! profile for carousel at Stack Overflow, Q&A for professional and enthusiast programmers

4/10/2013

Git aliases for bash and zsh

Tired of typing long shell commands when using git ?

One of my favourite long example is git log --oneline --graph --decorate - when you want to  see what is happening in you git project ( branches, merging... ) It is very, very long command, that is hard to type, but there is a better solution.

Depends of type of shell you are using - you can use aliases for often used git commands.  Alias is a shortcut for longer, and more complicated command. Example of built in alias is ls which executes "ls --color_auto".

To see a list of your aliases just type alias in terminal.
To temporary create alias, type for example alias server="Python -m SimpleHTTPServer"

If you want to permanently store alias, open your .bash_profile or .bashrc file and paste same line inside.

So to change git long --oneline --graph --decorate type alias gl=" git long --oneline --graph --decorate" and you are on.

If you are a bash user here is a link with bash aliases, that can be copied and pasted in your .bashrc file.

Since I am using ZSH ( Z shell), here is a link with zsh aliases.
You'll have to place them in your zshell config file.

Happy Coding.



No comments:

Post a Comment