Open In App

How to Set Up Git Using Git Config?

Last Updated : 16 Feb, 2022
Improve
Improve
Like Article
Like
Save
Share
Report

Git is a free and open-source version control system. It is used in software development. Git allows software developers to see the changes they made on the code, it gives them the ability to undo things if necessary and also helps a team of people to work together on a project.

Git can be downloaded as a software package on Windows, Mac, Linux platforms. After installing we need to configure the git. After configuration, we can only use it.  git config command helps users to do so.

Here we will be discussing the git config command.

Name and Email Setup

One of the first things that you will do is to set up your name and email address without this you cannot even perform any commit operation. 

The below codes will help us do so

$ git config --global user.name "Satyajit Ghosh"
$ git config --global user.email satya@example.com

Here is the terminal shell pictorial depiction after executing the above commands as follows:  

Default Editor Setup

There are times when git needs a text editor to take input from the user like merge conflict or renaming a commit etc. In those situations, git uses the default text editor of the system generally the Emacs. As per your preference, you may want to use any other text editor, You can do so by using git config.

Let’s suppose you want to make Visual studio code, your default text editor for the git. Then we need to use the following command

git config --global core.editor code

Here is the terminal shell pictorial depiction after executing the above command:

Now, whenever git requires to open a text editor it will open the Visual Studio Code.

Default Branch Name

Git uses “master” as its default branch name, we can change it to any other name using the git config command. Let’s suppose we want to make our default branch name “main” then we can use the following command –

git config --global init.defaultBranch main

Now if you want to see all the changes you have made so far using git config, you can do that using the following command as follows:

git config --list

Here is the terminal shell pictorial depiction after executing the above command:

In this article, we covered all the basic commands that you generally need, but if you want to learn more about the git config command then you try the below command in the terminal

git config --help

This will show you all the available flags of the git config command along with the documentation as depicted by the below terminal output as  follows:


Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads