git|July 07, 2020|1 min read

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

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.

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

Claude Code Skills — Build a Better Engineering Workflow with AI-Powered Code Reviews, Security Scans, and More

Claude Code Skills — Build a Better Engineering Workflow with AI-Powered Code Reviews, Security Scans, and More

Most developers use Claude Code like a search engine — ask a question, get an…

Building an AI Voicebot for Visitor Check-In — A Practical Guide to Handling the Messy Parts

Building an AI Voicebot for Visitor Check-In — A Practical Guide to Handling the Messy Parts

Every office lobby has the same problem: a visitor walks in, nobody’s at the…

Server Security Best Practices — Complete Hardening Guide for Production Systems

Server Security Best Practices — Complete Hardening Guide for Production Systems

Every breach post-mortem tells the same story: an unpatched service, a…

Staff Engineer Study Plan for MAANG Interviews — The Complete 12-Week Roadmap

Staff Engineer Study Plan for MAANG Interviews — The Complete 12-Week Roadmap

If you’re a Senior Engineer (L5) preparing for Staff (L6+) roles at MAANG…

XSS and CSRF Explained — The Complete Guide with Real Attack Examples and Defenses

XSS and CSRF Explained — The Complete Guide with Real Attack Examples and Defenses

XSS and CSRF have been in the OWASP Top 10 for over a decade. They’re among the…

OWASP Top 10 (2021) — Every Vulnerability Explained with Code

OWASP Top 10 (2021) — Every Vulnerability Explained with Code

The OWASP Top 10 is the industry standard for web application security risks. If…