Git Config and Git Aliases
Tags: git, productivity, github, bash
Published: 2021-07-16 23:57:18

Hey Guys🖐!! In this Blog I will tell you about git config command, Git aliases, which allow you to create shortcuts for frequently used Git operations. Becoming familiar with git config and the various Git configuration settings will help you create a powerful, customized Git workflow.
I have posted the video on Git Config and Git Aliases on my YouTube Channel so you can watch that Video for Detailed Explanation through video.
Link To Video - [Git Config and Git Aliases](https://www.youtube.com/watch?v=ANcQEnBjXyU&t=224s)
#What is Git Config 🤷‍♂️?
The git config command is a convenience function that is used to set Git configuration values on a global or local project level. These configuration levels correspond to .gitconfig text files.
In one line - "The git config command is a function that sets configuration variables"

##The git config levels and files

Mainly there are three config levels 

`--local`
When no configuration option is passed git config writes to a local level, by default.The repository of the .git directory has a file that stores local configuration values.

`--global`
The application of the global level configuration includes the operating system user. Global configuration values can be found in a file placed in a user's home directory.

`--system`
The System-level configuration includes all users on an operating system and all repositories. System-level configuration is applied across an entire machine. System-level configuration file is located in a git config file of the system root path.

> NOTE: the order of priority for configuration levels is: local, global, system. This means when looking for a configuration value, Git will start at the local level and bubble up to the system level.
![git_cinfig](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nugfa7qzkex8qs0wkmv9.PNG)

## Configuring Name and Email in Git Bash : 

Let's First check whether our name and email are set or not : 
```
git config user.email  
```
```
git config user.name
```
If your Email and name are not set you can set them by:
```
git config user.email "abc@gmail.com"
```
```
git config --global user.name "first_name last_name"
```
###Color.Ui✨
Git comes with another property of providing color to the outputs. By default I think it is set to auto. 
**If your git color ui is not enabled you can enable it by the command :**
```
git config --global color.ui true
```
To make it set to auto apply this command:
```
git config --global color.ui auto
```
For disabling all Git's colored terminal output you can do the following:
```
git config --global color.ui false
```

##Git Aliases 🎉
Git Aliases are custom shortcuts that define which command will expand to longer or combined commands. Aliases save you the time and energy cost of typing frequently used commands. Git provides its own alias system.
And every developer want his code to be short and clear to make it understand properly and conserve his time so that he can make that time useful to develop other things😋.
Git aliases are stored in Git configuration files.

**Example :** You do `git commit -m "new commit"` but with git commit you can do it simply by `git cm "new commit"`

The general git config command used to configure aliases is:
 ![aliases](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/g209gl3sfpex3ug9on8e.PNG)
> NOTE: We will set aliases globally because we require alias to be set for our whole  Operating System.

Now let's see some git alias:
```
$ git config --global alias.co checkout
$ git config --global alias.br branch
$ git config --global alias.ci commit
$ git config --global alias.st status
```
####Changing git aliases at any time :
You can Change, Delete or add new aliases by these ways: 
**Command on git Bash -**
Changing or Deleting -
```
git config --global --unset alias.<alias>
```
**Editing on Vim or VsCode Editors**
Changing, Adding or Deleting - 
```
vim ~/.gitconfig
```
```
code ~/.gitconfig
```
To See all your Global config file setups including email, name, color.ui, aliases and more use the command :
```
cat .gitconfig
```
![shows all details](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/o0d0nmjmks5j1ezm9huf.png)

#Summary👉

I hope this Blog was helpful in improving your Git workflow. If you have any queries or suggestions, let’s discuss in the comment section.
If you all like the content and got to learn something new please give a ❤ and 🦄. 
To learn more about Git, GitHub, Git Config or any code related stuff Please go to my [YouTube Channel](https://www.youtube.com/channel/UCcAsN-6g9KWAVxXFcVVKhkg) and subscribe if you want more of such learning.
Dedicated video link on this topic - [Video Link](https://www.youtube.com/watch?v=ANcQEnBjXyU&t=224s)

Thank You and Happy Learning😎!!