Git is an intricate part of our development workflow. There are handful of commands that you keep repeating day in and day out. I always relied on the command suggestions, or packages on top of my shell that gave access to handy git aliases.

But usually you had to stick with the aliases decided by the package creators . Although most of the aliases included are unofficially globally accepted like ga for git add and so on.

But guess what? You don’t have to rely on any third party packages ; you can create your own with the aliases you prefer!

There are two ways of creating Git aliases: ✌

with the git config utility 💻

This is the preferred way of adding aliases as git gives you an option to do so. Suppose you feel tired of repeating the commit command every now and then. It would be nice if we could create an alias to write our commits faster.

The above command follows the following syntax:

Now we can use the c alias to represent commit -m .

git c "Update readme with social links"

editing the .gitconfig file 📝

It would be tedious to add multiple aliases with the git config command, so there’s an easier alternate approach.

All the alias you create is saved to the .gitconfig file sitting in your home directory. We can open the file and add our aliases following the TOML formatting. Make sure you do not modify anything in the file apart from adding the [alias] table and its contents.

Open the file using your favorite editor.

vim ~/.gitconfig ## or code ~/.gitconfig

Start adding your alias ✍️

You can use the above aliases as follows:

git st ## git status 
git c "hello world" ## git commit -m "hello world" 
git a hallucination.py ## git add hallucination.py 
git cb multi-stage-build ## git checkout -b multi-stage-build

#command-line #git #github #productivity #programming

Faster Git Workflow With Git Aliases
1.50 GEEK