Free cookie consent management tool by TermsFeed Generator How to use Git Alias to increase your productivity (video) | Amir Kamizi
AMIR KAMIZI
Home Blog Courses Books Newsletter Store Membership Buy me a coffee
How to use Git Alias to increase your productivity (video)

How to use Git Alias to increase your productivity (video)

Last Updated on Nov 27, 2022

https://youtu.be/bUCIVgfs30o

 

Transcription

Hello

This is amir

Today we are going to talk about Git Alias and how to increase your productivity by adding shorter aliases for commands that we use everyday

So let’s get started

What is Alias

First of all, what are aliases?

Well aliases are like shortcuts for a command.

Instead of writing the full command you can just run the short version.

For example, Instead of writing

Git checkout master

You would write

Git com

The cool part is that you can combine multiple commands and give them an alias

For example you can combine

Git checkout master

and

Git add .

and

Git commit -m

To one command.

Enough teasing let’s see how we can do it

How to Add a git alias

In order to add a new alias, You should run this command:

git config --global alias.<your-alias> ‘<command>’

If you want the alias to work only for this project then remove the –global flag

And if the command you are aliasing starts with git add ! in the beginning

Examples

Let’s see some examples:

Example 1

I want to have com as the alias for

Git checkout master

And I only want this alias to work in this project so I won’t write the –global flag

Let’s do it

Git config alias.com ‘checkout master’

Or I could write the full command and add !

Git config alias.com ‘!git checkout master’

And let’s test it now

Git com

Perfect now we are in the master branch

Example 2

Second example is to see how we can combine multiple commands in one alias.

One of the things I use a lot is git add . and git commit

So I want to combine those to commands in an alias something like add-commit or acm 

Let’s do it now

git config alias.acm '!git add . & git commit -m'

Ok let’s test it

First let’s see the changed files by running

git status

And now let’s run our alias

git acm

Perfect it has added everything and committed everything

Awesome!

Practice

Let’s practice together

Question

I use this command a lot

git log -1 head

This shows only the last log

I want to make an alias for it with the name last

And I want this alias to run only in my local project not globally

How can I do it?

Pause the video

Try to do it

Write your answer in the comment and then play the video to see the answer

Answer

Ok now let’s see the answer.

we want to add a new alias called last and it shouldn’t be a global alias.

To do that we should run this command

Git config alias.last '!git log -1 head'

And let’s see if it works

Great it works!

Was your answer correct?

Key Takeaways

Just a quick recap

  • We talked about adding alias for git commands
  • We created an alias for a single command and we also combined multiple commands and gave them an alias

Final Words

And finally, if you liked what you learned please like and subscribe.

That would be a great motivation to do more videos.

If you have any suggestions or questions please leave a comment below and I try to answer them as soon as possible

That’s it

Have a wonderful day.

You can watch the original video on youtube.

Category: programming

Tags: #git

Join the Newsletter

Subscribe to get my latest content by email.

I won't send you spam. Unsubscribe at any time.

Related Posts

Ultimate guide to RESTFul API Versioning in PHP Laravel: 2 solutions
Feb 15, 2023 programming

Ultimate guide to RESTFul API Versioning in PHP Laravel: 2 solutions

API versioning is what you need if you want to change the behavior of your API or the structure and format of requests and responses. ...

17 Min Read Read More
PHP Conditionals
Mar 21, 2023 programming

PHP Conditionals

Today we are going to learn about conditionals in PHP. Conditionals are very useful in any programming language. So important that we can argue that the foundation for all the technologies around us are conditions. ...

7 Min Read Read More
A Programmer's Guide to Debugging: Essential Steps to Follow
Mar 23, 2024 programming

A Programmer's Guide to Debugging: Essential Steps to Follow

Debugging is a crucial skill for any programmer, as it helps identify and fix issues in the code. Effective debugging not only improves the overall quality of your software but can also save you time and frustration. ...

10 Min Read Read More
Alpine.js Beginner to Advanced 2025: Everything You Need to Know
Jul 18, 2025 programming

Alpine.js Beginner to Advanced 2025: Everything You Need to Know

JavaScript frameworks have exploded in popularity over the past decade, but not every project needs—or benefits from—the complexity of tools like React or Vue. Sometimes, all you want is to sprinkle interactivity into your HTML without a heavy build process. This is exactly where Alpine.js shines. ...

29 Min Read Read More

Recommended Courses

Introduction to Machine Learning in PHP

Introduction to Machine Learning in PHP

Learn to Build Different Machine Learning Models Easily ...

PHP Tutorial Beginner to Advanced

PHP Tutorial Beginner to Advanced

Learn everything you need to start a successful career as a PHP developer ...