Shorten git commands with git aliases

Shorten git commands with git aliases

Git aliases, my friends, are like shortcuts to your favorite git commands. And setting them up is as easy as pie! All you gotta do is whip out the git config command and BOOM! You got yourself a brand new alias. Just remember to swap out [insertYourShortcut] and [gitCommand] with your own special ingredients. Now, go ahead and make your terminal experience extra sweet!

Why this article dude?

Tired of typing those long, tedious git commands every single day? Fret not! Git aliases to the rescue! With git aliases, you can create your very own short and snappy commands for your most frequently used git commands. Say goodbye to boredom and hello to lightning-fast git commands!

What's Git again?

Git is like a magical wizard that helps keep track of all your code's changes and makes sure you never lose any important spell (or code). It's like a time machine that lets you go back and forth between different versions of your code like it's no big deal. So, if you're a wizard (or a coder), you better make friends with Git, because you're gonna need its help!

Setting up a new alias is as easy as pie! All you have to do is use the trusty git config command. It's like magic, just type in the command, and bam! Your new alias is ready to use. So go ahead, give your fingers a break and make your git game strong with some sweet aliases.

Some of the alias I personally use:

git config --global alias.b branch
git config --global alias.c checkout 
git config --global alias.c checkout 
git config --global alias.cm 'checkout master' 
git config --global alias.cb 'checkout -b' 
git config --global alias.st status 
git config --global alias.ci 'commit -m' 
git config --global alias.p pull 
git config --global alias.pu push 
git config --global alias.a 'add .'

But how can I create one?

Just type the following command into your terminal and don't forget to replace [insertYourShortcut] and [gitCommand] with your command and shortcut.

git config --global alias.[insertYourShortcut] [gitCommand]

How to use these aliases?

You just have to type git [aliasShortcutName].

Let us say you wanna pull the repo from the origin just type git p and git pu to push the changes to master based on the alias we have created.

PRO-TIP

Type this to show all of the aliases you have created:

$ ! git config --get-regexp ^alias\. | sed -e s/^alias\.// -e s/\ /\ =\ /

And that folks, is how you spice up your git game with some fun and funky aliases. No more typing out those long and boring commands, just sit back and let your fingers do the talking. Who needs long commands when you have short and sweet aliases, right? Until next time, keep on git-ting'!

Did you find this article valuable?

Support Harsh Vardhan Goswami by becoming a sponsor. Any amount is appreciated!