How to use Git Alias to increase your productivity (video)
Last Updated on Nov 27, 2022
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
You would write
The cool part is that you can combine multiple commands and give them an alias
For example you can combine
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:
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
Let’s see some examples:
I want to have com as the alias for
And I only want this alias to work in this project so I won’t write the –global flag
Let’s do it
Or I could write the full command and add !
And let’s test it now
Perfect now we are in the master branch
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
Ok let’s test it
First let’s see the changed files by running
And now let’s run our alias
Perfect it has added everything and committed everything
Let’s practice together
I use this command a lot
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
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
And let’s see if it works
Great it works!
Was your answer correct?
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
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
Have a wonderful day.
Link to Video:
You can watch the original video on youtube.