This article will explain the installation of the git environment and how to set up its variable on the Linux system. All steps we have performed on the Ubuntu 20.04 system in this article.
Prerequisites
You should have root account access, or you can run commands with ‘sudo’ privileges.
Installation of Git environment on Ubuntu 20.04
To install and Setup Git environment on your Ubuntu 20.04 system, you need to update the apt repository, that you can do by running the below-mentioned command:
The following command you will use to install the git-core package:
Once the installation of git is complete, now check the installed version by issuing the following command on the terminal:
As you can see in the above screenshot Git is installed on this system and working.
Customize Git Environment Variables
To set the Git environment variable, Git provides the git config tool. All the Git global configurations are stored in a .gitconfig file. This file you can easily locate in your system’s home directory. You need to set all configurations in global. Therefore, use the –global option, and if you do not use this option, then all configurations will set for the currently working Git repository. Users can also set up system-wide configurations. All the values in a Git store are in a file /etc/gitconfig that contains the complete configuration about every user and each repository on your system. If you want to configure or set these values, then you should have root privileges and use option –system with command.
SettingUser name
Setting the user.name and user.email information will show you in your commit messages. Set the user.name by using the following command:
Set User email
Similarly, you can your git email by running the below-given command:
Set other configurations
You can create some other configuration related to avoiding pull merge commits, color highlighting, etc.
To avoid merge commits pulling, you can set by using the following command:
To set the option related to color highlighting for Git console, use the below command:
$ git config --global color.status auto
$ git config --global color.branch auto
By using the gitconfig file, you can set the default editor for Git.
You can also set the default merge toll for Git as follows:
Now, use the following command to show the Git settings of the local repository:
The following result will show on your output screen:
Conclusion
We have performed how to set up the Git environment and variables configurations of Git on Ubuntu 20.04 in this article. Git is a very useful software environment that offers many features to all developers and IT users. I hope now you can set up the Git environment on your Ubuntu system, and you can easily change or set its configurations on your system.