git1 Min Read

A Practical Guide on how to to create your own git command alias

Gorav Singal

July 07, 2020

TL;DR

Create Git command aliases using git config to shorten frequently used commands like git log --oneline --graph --decorate into a short, memorable alias.

A Practical Guide on how to to create your own git command alias

Introduction

In this guide, We will learn on how to create some handy command alias.

Example git log command

In previous post Git log commands, we see how we can try various git commit history output.

git log --oneline --graph --decorate

Lets try to create our git command alias, so that we don’t need to type this long command again and again.

Git command alias

Lets create git command alias globally for system.

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

In above command, the keyword alias., is a special keyword. Anything after that will become git alias name after the command.

So, we created a git alias with name nicelog. See, how we can use it.

git nicelog

Now, this will give me output same as if I’m running: git log --oneline --graph --decorate

Modify Git alias

Open ~/.gitconfig file in an editor. You will see a section something like:

[alias]
  nicelog = log --oneline --graph --decorate

Just change the command in that file, save it. Exit.

And, now if you run the command. It will reflect the changes you made.

Share

Related Posts

A Practical Guide in understanding Git Branch and Conflict resolution during merge

A Practical Guide in understanding Git Branch and Conflict resolution during merge

Introduction In this guide, We will learn about branching, handling conflict…

A Practical Guide on Understanding Git Best Practices

A Practical Guide on Understanding Git Best Practices

Introduction In this post, we will learn about some of Best practices while…

A Practical Guide on how to work with Git Basic Commands and workflows

A Practical Guide on how to work with Git Basic Commands and workflows

Introduction In this guide, we will see git basic commands, and fundamentals of…

A Practical Guide on how to work with Git log command and history

A Practical Guide on how to work with Git log command and history

Introduction In this post, we will see ways to look at git history logs. For…

A Practical Guide for better understanding Git Diff

A Practical Guide for better understanding Git Diff

Introduction In this guide, We will get basic understanding of various options…

Git - How to create a Pull Request with no history of commits

Git - How to create a Pull Request with no history of commits

Introduction If you working on a github project in a team. Consider you have…

Latest Posts

AI Video Generation in 2025 — Models, Costs, and How to Build a Cost-Effective Pipeline

AI Video Generation in 2025 — Models, Costs, and How to Build a Cost-Effective Pipeline

AI video generation went from “cool demo” to “usable in production” in 2024-202…

AI Models in 2025 — Cost, Capabilities, and Which One to Use

AI Models in 2025 — Cost, Capabilities, and Which One to Use

Choosing the right AI model is one of the most impactful decisions you’ll make…

AI Image Generation in 2025 — Models, Costs, and How to Optimize Spend

AI Image Generation in 2025 — Models, Costs, and How to Optimize Spend

Generating one image with AI costs between $0.002 and $0.12. That might sound…

AI Coding Assistants in 2025 — Every Tool Compared, and Which One to Actually Use

AI Coding Assistants in 2025 — Every Tool Compared, and Which One to Actually Use

Two years ago, AI coding meant one thing: GitHub Copilot autocompleting your…

AI Agents Demystified — It's Just Automation With a Better Brain

AI Agents Demystified — It's Just Automation With a Better Brain

Let’s cut through the noise. If you read Twitter or LinkedIn, you’d think “AI…

Supply Chain Security — Protecting Your Software Pipeline

Supply Chain Security — Protecting Your Software Pipeline

In 2024, a single malicious contributor nearly compromised every Linux system on…