| by Arround The Web | No comments

Git: Different Ways to Reset Git Config File

The Git config file contains the terminal configuration. It customizes the Git environment by utilizing the “git config” command. Users can set the username, email, default editor, default branch, and many more in the configuration file through the previously described. More specifically, Git allows users to reset these variables according to their needs.

This study will describe the various possible ways to reset the Git config file.

Possible Ways to Reset Git Config File

There are different ways to reset the configuration file in Git, such as:

How to Reset the Git Config File by Specifying Scope?

To reset the Git configuration file, follow the below-provided instructions.

Step 1: View Git Config File Content

First, display the content of the Git configuration file using the below-provided command:

$ git config --list

Step 2: View Specific Scope Content in Config File

Then, utilize the previous command along with specific scope to display its content:

$ git config --global --list

Here, the “–global” option is used to display the content of the global scope in the configuration file:

Step 3: Reset the Specific Scope

Next, specify the scope to unset its content by typing out the provided command:

$ git config --global --unset-all core.editor

Step 4: Verify Changes

Lastly, verify the changes by viewing the global configuration file content:

$ git config --global --list

It can be seen that the user-defined settings, such as “user.name”, “user.email” and “core.editor” has been removed:

How to Reset the Git Config File by Specifying the Section?

To reset the Git configuration file by specifying the scope, check out the following steps:

Step 1: View Specific Scope Content

First, execute the below-listed command and specify the scope to view its content:

$ git config --local --list

Here, the “–local” option is used to display the local scope content.

In the below-screenshot, different sections, such as “core”, “remote”, and “user” can be seen. Choose the section that needs to be reset. For instance, we have selected the “user” section:

Step 2: Reset the Section

Now, reset the desired section by utilizing the following command:

$ git config --local --remove-section user

Step 3: Verify Changes

View the scope content to verify the rest changes:

$ git config --local --list

The below output indicates that the “user” section has been removed from the “local” scope in the configuration file:

We have provided different methods to reset the Git configuration file.

Conclusion

There are different possible ways to reset the configuration file in Git. Users can rest the configuration file by specifying the scope or section. The “git config –<scope> –unset-all core.editor” command is used to reset the specific scope and to reset the particular section in scope, the “git config –local –remove-section <section>” command can be used. This study described different ways to reset the Git configuration file.

Share Button

Source: linuxhint.com

Leave a Reply