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
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"
Mainly there are three config levels
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.
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.
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.
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 "email@example.com"
git config --global user.name "first_name last_name"
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 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"
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
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 -
To See all your Global config file setups including email, name, color.ui, aliases and more use the command :
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 and subscribe if you want more of such learning.
Dedicated video link on this topic - Video Link
Thank You and Happy Learning😎!!