How to create a git alias

Posted in Uncategorized

Tweet This Share on Facebook Bookmark on Delicious Digg this Submit to Reddit

Tired of typing “git checkout” all the time. Create a git alias so that you can type “git co” instead by …

git config --global alias.co checkout

That is two hypens before the “global”.

To see the list of configs that you have …

git config --list

To list only the alias, pipe it through grep like this…

git config --list | grep alias

The above example show one of the most common git alias that people tend to set up since “checkout” is such a long word to type and “co” is such a memorable shortcut.

Another common alias is “st” for “status” since “git status” is used so frequently. Create the alias with …

git config --global alias.st status

You can create alias of longer commands by putting the command in quotes. Here is an handy alias of the long log command with options …

git config --global alias.lg "log --graph --oneline --decorate"

Now typing “git lg” will give you a “git log” with decorate graph in oneline.

Note that it is “oneline” and not “online”.


Related Posts

Tags

Share This