Product SiteDocumentation Site

3.3.2. Initial Setup

After installing there are a few steps to personalize Git and get it ready for use. These only need to be set up once and Git will remember the settings, however if they need to be changed in the future just run the commands again.
These changes are made by altering variables stored in three different places:
  1. The /etc/gitconfig file contains variables for every user on the system and all their repositories. It holds the base settings and passing --system to git config sets it to read and write from this file.
  2. The ~/.gitconfig file is specific to the user. Passing --global tells Git to read and write to this file, overriding the settings made in the first point.
  3. The config file in the Git directory (.git/config) of the repository currently being used. This is specific to this repository only and override the settings in both the first and the second point.
Before the first commit, enter some details into Git by supplying the name and email address that will appear with change.
For example, if the user's name is John Q. Smith, use the following commands:
$ git config --global user.name "John Smith"
$ git config --global user.email "jsmith@example.com"
As explained above, by passing the --global option this only needs to be set once, but can be overridden for specific repositories.
By default, whenever an editor is needed, Git launches Vi or Vim. However, if this is not preferred it is possible to change this to another editor. To do so, use the following command:
git config --global core.editor EditorName
The diff tool is often used to view the changes in various files, useful for double checking things before committing them. Git currently accepts the following meld diff tool.
Use the following command to set the preferred diff tool:
$ git config --global merge.tool DiffTool
Finally, it is useful to check these settings to ensure they are correct. To do this run:
$ git config --list
user.name=John Smith
user.email=jsmith@example.com
If there are different settings in different files, Git will list them all, with the last value for the active one. It is also possible for Git to check the specific response to a variable by using the git config {key} command. For example:
$ git config user.name
John Smith