24 C
Jaipur
Saturday, September 18, 2021

Git environment and environmental variables setup – Linux Hint

Must read

Git is a freely available distributed version control software under the conditions of GNU (General Public Licence version 2). This system is used for source code management with a high emphasis on efficiency and speed. Linus Torvalds was initially designed and developed Git for Linux kernel development. It is an open-source tool that is easy to learn and has a lightning-fast performance. It supports various SCM tools, like CVS, Subversion, Perforce, and ClearCase, providing the features of multiple workflows, cheap local branching, and convenient staging areas.

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:

$ sudo apt install git-core

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:

$ git config –global user.name “karim buzdar”

Set User email

Similarly, you can your git email by running the below-given command:

$ git config –global user.email karim.buzdar@gmail.com

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:

$ git config –global branch.autosetuprebase always

To set the option related to color highlighting for Git console, use the below command:

$ git config –global color.ui true
$ 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.

$ git config –global core.editor vi

You can also set the default merge toll for Git as follows:

$ git config –global merge.tool vimdiff

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.

Source link

- Advertisement -

More articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisement -

Latest article