3 Configuring Global Settings For Git

Before starting to use Git, you should configure it with some important settings that won’t change as you use Git. You may configure options both globally, and on a per-repository basis. Here, we discuss only global configuration settings.

You can configure Git using either ‘git config’, or by editing the relevant files with your favorite text editor.3

The first things to set are your email address and your real name:

$ git config --global user.name "J. P. Developer"    Set full name
$ git config --global user.email jpdev@example.com   Set email address

Setting these two items are an absolute requirement. Note: No aliases are allowed. If you can’t supply your real name, you cannot contribute to the project. Other options that the gawk maintainer recommends that you use are:

$ git config --global push.default simple    Only push the current branch
$ git config --global pager.status true      Use pager for output of git status

The global settings are stored in the .gitconfig file in your home directory. The file looks like this:

[user]
        name = J. P. Developer
        email = jpdev@example.com
[push]
        default = simple
[pager]
        status = true

The push.default=simple setting ensures that older versions of Git only push the current branch up to the Savannah repo. This is the safest way to operate, and is the default in current Git versions.

There may be other settings in your configuration file as well. Use ‘git config’ to see your settings:

$ git config --list
-| user.name=J. P. Developer
-| user.email=jpdev@example.com
-| push.default=simple

Here are the gawk maintainer’s settings:

$ git config --global --list
-| user.name=Arnold D. Robbins
-| user.email=arnold@…
-| credential.helper=cache --timeout=3600
-| push.default=simple
-| color.ui=false
-| core.autocrlf=input
-| pager.status=true
-| log.decorate=auto

Additional, per-project (“local”) settings are stored in each repo’s .git/config file.


Footnotes

(3)

You are required to use either Vim or Emacs, other text editors are not allowed. Of course, reasonable developers wouldn’t want to use any other editor anyway.