Jump to content

Git environment and environmental variables setup


Linux Hint

Recommended Posts

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:

$ sudo apt update

The following command you will use to install the git-core package:

$ sudo apt install git-core

word-image-94.png

Once the installation of git is complete, now check the installed version by issuing the following command on the terminal:

$ git --version

word-image-95.png

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"

word-image-96.png

Set User email

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

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

word-image-97.png

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

word-image-98.png

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

word-image-99.png

By using the gitconfig file, you can set the default editor for Git.

$ git config --global core.editor vi

word-image-100.png

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

$ git config --global merge.tool vimdiff

word-image-101.png

Now, use the following command to show the Git settings of the local repository:

$ git config --list

The following result will show on your output screen:

word-image-102.png

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.

View the full article

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...