~/git/practical-guide-git-how-create-git-command-alias.md

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

1 min readJuly 07, 2020by Gorav Singal#git
// 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.

$ subscribe --weekly

One deep dive a week, in your inbox

System design, AI engineering, trading systems and interview prep. Tested code, real numbers. Free, and you can unsubscribe any time.

or read it on gyanbyte.substack.com

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 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 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 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

How to Stay Valuable as a Software Engineer in the AI Era: A Practical Playbook

How to Stay Valuable as a Software Engineer in the AI Era: A Practical Playbook

In the previous article I argued that AI is not killing software engineering…

How to Review AI-Generated Code: A Checklist for Catching What the Model Missed

How to Review AI-Generated Code: A Checklist for Catching What the Model Missed

A few months back I approved a PR that was almost entirely AI-generated. It…

How to Debug AI-Generated Code: Understand First, Fix Last

How to Debug AI-Generated Code: Understand First, Fix Last

In the last article I wrote about reviewing AI code before it goes in. This one…

The Future of Software Engineering: What AI Changes, What Stays, and Where the Jobs Go

The Future of Software Engineering: What AI Changes, What Stays, and Where the Jobs Go

Every few weeks somebody sends me a scary headline — “AI will replace all…

The Transactional Outbox Pattern: Never Lose an Event Again

The Transactional Outbox Pattern: Never Lose an Event Again

This is one of those patterns that looks like nothing until you get burnt once…

Event Sourcing, Explained: Store What Happened, Not Just the Final State

Event Sourcing, Explained: Store What Happened, Not Just the Final State

Here is a question I like to ask in interviews: your bank account shows a…