When I create a new git repository, some configurations settings are automatically added to .git/config. Where can I change these default settings?
2 Answers
Considering the option template of git init
:
--template=<template_directory>
Provide the directory from which templates will be used. The default template directory is
/usr/share/git-core/templates
.When specified,
<template_directory>
is used as the source of the template files rather than the default.
The template files include some directory structure, some suggested "exclude patterns", and copies of non-executing "hook" files. The suggested patterns and hook files are all modifiable and extensible.
If you look at the git sources for creating a new db, you could include a config file with your default value there.
The function create_default_files()
does have:
/* First copy the templates -- we might have the default
* config file there, in which case we would want to read
* from it after installing.
*/
copy_templates(template_path);
The git/config.c has the git_default_core_config()
function which set default values.

- 1,262,500
- 529
- 4,410
- 5,250
-
1@Jubobs I have restored the link. – VonC Oct 05 '14 at 15:12
-
1Looking at the code, it seems that the settings are determined automatically and cannot be changed. E.g. I want to change the default setting for core.filemode, but this is hardcoded based on a check ("`/* Check filemode trustabililty */`"). – donquixote Aug 17 '16 at 00:28
-
3I added a file `/usr/share/git-core/templates/config`, with `filemode = false` and a random `xyz = foo` in the `[core]` section. The `xyz = foo` works, but the `filemode = false` is overwritten thanks to the hardcoded logic mentioned above. – donquixote Aug 17 '16 at 00:30
All git global configs can be altered by the --global
supplied at the command line.
For eg:
git config --global user.name "First Last"
git config --global user.email "email@somewhere.com"
Update:
All existing git configs can be found by
git config -l
Also, git config -e
opens an editor for editing.

- 84,407
- 47
- 135
- 168
-
12The question was about default values that are written to _local_ config in every newly-created repository. This has nothing to do with global settings, because local config overrides global one. – Rast Feb 19 '15 at 12:13