How to use Git Config Global in Ubuntu
Firstly, you have to access the “.gitconfig” file by using Ubuntu terminal; there are multiple ways to edit this file, the easiest way is by using the following command in terminal:
Adding variable and properties inside Git config global : The “.gitconfig” primarily deals with the variables and the properties associated to these variables: In case you want to add the properties directly using terminal then you can use the command written below:
The below mentioned commands will add name of user and email of that user to the “.gitconfig” file:
$ git config --global user.Email linuxhint@example.com
You can add new variables in Git config global file by using “–add” flag; For instance, the command written below will add the variable “editor” and set the name property of this variable:
Getting the content of Git config global : Once you have made changes, you can verify the changes by issuing the command stated below; it is observed that the changes made in the above section are displayed in the output. Additionally, the path of the config file is also shown alongside each property:
Or you can get the changes by using the command mentioned below:
The difference between both commands is the display of path: the “–showorigin” displays the path of the file where changes are made:
Checking the editor of Git Config Globals : You can check the editor by opening the “.gitconfig” file using the command mentioned below; this command will automatically open the file in the default editor, in our case it is nano as shown in the image below:
Changing Git Global editor : By default, the “.gitconfig” is opened in nano text editor; if you want to change the default editor, the following commands will assist you to set the editor of your own choice:
For instance, if you want to set atom editor for Git config global then copy and paste the command written below in your Ubuntu terminal:
Or you can execute the command mentioned below to set “vim” as default editor for “.gitconfig” file:
How to unset editor of Git config global : One can add multiple properties inside “.gitconfig” file and also can change the default editor of this file: in case, you want to reset the changes to default; you can do so by using the “–unset” flag of “Git config global” command:
To unset the changes related to editor; use the command mentioned below; this command will remove all the changes that were made on “core.editor”:
Conclusion
Git has eased the working structure of multiple organizations and especially the programmers around the globe; these repositories produce fruitful results in a collaborative working environment. Moreover, Git repositories are backed up by GitHub to provide cloud-based access to Git repositories that means files can be accessed locally as well as globally too. In this descriptive guide, we have provided the detailed usage of the Git config command at its global level; this global level of Git config is associated with the “.gitconfig” file. We have discussed the editing operations and the fundamental usage of this command. Moreover, the major editing functions discussed in this guide include: the properties and changing the editor of this file.