In this tutorial we will learn to configure Git.
Git has a tool called git config to customize the Git environment. It lets us to get and set the configuration variables.
We can set the configuration at three level.
The global config will override the system level config. The local config will override the config set at the global and sytem level.
This configuration is applied across an entire machine covering all users of the operating system and all repositories.
System level configuration resides in gitconfig file under system root on Unix system.
This configuration is applied to an operating system user and resides in a .gitconfig file under user directory.
This configuration is applied to a repository. And it is a default configuration if no option is mentioned.
After installing Git the first thing we need to do is set the user name and email address. This two information is used in every Git commit. More on commit later.
This setting is done once using the --global option.
To set the user name at the global level we use the following command.
$ git config --global user.name "Yusuf Shakeel"
To set the user email at the global level we use the following command.
$ git config --global user.email "email@example.com"
To get the user name we type the following command.
$ git config user.name
To get the user email we type the following command.
$ git config user.email
We use the alias to create custom shortcut for different commands.
To create an alias to check the status we can type the following command.
$ git config --global alias.s status
The above code create an alias for the git status command. (More on git status command in the later tutorials).
So, when we type the following in a repository we get the status of the repo (repository).
$ git s
On branch master
Your branch is up-to-date with 'origin/master'.
nothing to commit, working tree clean
To list all the configuration we use the --list option.
$ git config --list
Have fun learning :-)
Copyright © 2014 - 2019 DYclassroom. All rights reserved.
rendered in 0.0144 sec