Now as we have git already installed in our system, we would like to customize few things such as our identity by which we will be committing our changes and pushing files, setting our favorite editor while running git interactive commands, etc.
These configurations are managed by the command
$ git config
To view the current setting, you can run the below in terminal or if you are using windows in the command prompt
$ git config --list --show-origin
Setting Your Identity
As soon as you Install git, the first thing that you need to do is to set your Username and Email Address, because when we commit any changes, git uses this information to bind it with every commit.
To set your Identity, run the following command with your Username and email address.
$ git config --global user.name“Rahul" $ git config --global user.email email@example.com
Note: You will be required to do this only once since we are using –global option, which sets the above property at the system level. Even if you create a new user account, the properties will be saved across all accounts.
Setting Your Favorite Editor
Now that we have our identity set up, we’ll be required to configure default editor that we will be using when we are working with git with the interactive command which requires user inputs. If not set, the system’s default editor will be selected.
Suppose you want to set atom as a default editor, you can key in below
$ git config --global core.editor “atom --wait"
OR use the sublime text editor
$ git config --global core.editor “subl --wait"
The –wait is required, as it allows text to be typed and wait for it to be saved close.
In Windows, we need to specify the complete path of the text editor program you want to make it as a default text editor for git. Suppose, we want to use Notepad++, then we will be required to specify the full path of it, below is the command to do the same.
The below command holds good for Notepad++ installed in 64 bit Windows Operating System, if running on 32-bit operating system, our software is installed in ‘C:/Program Files(x86), replace the full path with the same.
$ git config --global core.editor "'C:/Program Files/Notepad++/notepad++.exe' -multiInst -nosession"
In this tutorial you’ve learned how to customize your identity when using git, and how to set your custom favorite text editor when running interactive commands in git. In the next tutorial, we’ll see how do we create our first repository to work with git.