Git Configuration Options

You can set various Git configuration options within your repository. This configuration option list can be viewed by running the git config command, passing in --list as an option.

$ git config --list

You can then set a configuration option by typing git config [option] [value].

Set the Git username

To set the Git username, you can write the following.

$ git config user.name 'John Doe'

This will set the username for this local repository. If you want to set Git configuration options globally, you can pass in the --global argument.

$ git config --global user.name 'John Doe'

Set the Git email address

You can set an email address associated to a Git repository by using user.email.

$ git config user.email 'johndoe@example.com'

Git File Permissions

To make Git ignore changes that have been made to file permissions, you can use the core.filemode configuration option and setting it to false.

$ git config core.filemode false

Git Editor

If you want to set the editor for Git, use core.editor.

$ git config core.editor "vim"

Change Git Output Colours

Git automatically colours most of its output. This can be switched off using the color.ui option and setting it to false.

$ git config color.ui false

The value of color.ui is auto by default. There are a variety of colours you can set:

[color]
  diff = auto
  status = auto
  branch = auto
  interactive = auto
  ui = true
  pager = true

This allows you to control what you want to have coloured in what way.

[color "status"]
  added = green
  changed = red bold
  untracked = magenta bold

[color "branch"]
  remote = yellow

For example, to change the status changed and status untracked colours, you can run the following:

$ git config color.status.changed blue
$ git config color.status.untracked magenta

Set the Git Merge Tool

Git will launch a merge tool in the event of a merge conflict. The program used to resolve the merge conflict can be set using the merge.tool configuration option.

$ git config merge.tool kdiff3