Let’s Create A GIT Alias

L

Problem

You have a specific command with lots of arguments that you need to run regularly, but you typing the specific arguments has gotten more repetitive than you’d like.

Solution

A nice git alias will do the trick.

First, we’ll take a complex git command, like the one below.

git log --graph --pretty='%C(bold yellow)%h%Creset  %s  %C(cyan)%ce%Creset'

Next, we’ll come up with a name for this alias. For this example, we’ll just call it prettylog.

Now, we’ll execute the following command to add it to your git profile.

git config --global alias.prettylog "log --graph --pretty='%C(bold yellow)%h%Creset  %s  %C(cyan)%ce%Creset'"

Now that the alias has been added, let’s test it by executing the following:

git prettylog

And now, we’re done. Creating a good alias will save you tons of keystrokes over time, and will make it easier to get to the data that you need.

Cliff Notes

Replace the placeholders in the commands below

git config --global alias.youraliasnamehere "your git command here"
git youraliasnamehere
About Me

I’m a San Diego-based software developer & Dev-Ops engineer with a passion for anything relating to technology. I like well-documented code & living near the beach, but I don’t like sand.

Add Comment

About Me

I’m a San Diego-based software developer & Dev-Ops engineer with a passion for anything relating to technology. I like well-documented code & living near the beach, but I don’t like sand.

Social

Need to get in touch?

Recent Posts