0

I know about the differences between System, Global and Local configurations in Git. And I know local configurations are stored in .git/config file

However, when I do a fresh clone of the repository, the local config is already populated, so for instance I see:

[core]
repositoryformatversion = 0
filemode = false
bare = false
logallrefupdates = true
symlinks = false
ignorecase = true

My question is - where do these default local configurations come from, and how can I change these defaults?

I know I can change my local configuration, but I have two problems with that:

  1. Next clone will get same defaults, which I don't want
  2. I maintain a repository for several users, so I want it to change for everybody

Thanks in advance

Rafael Dazcal
  • 315
  • 1
  • 4
  • May be such a thing (committing actual .git/config) is not possible otherwise such questions wouldn't have existed (https://stackoverflow.com/questions/18329621/storing-git-config-as-part-of-the-repository). May be somewhere local config linking is used in your settings (using `include.path` parameter). Check the linked question for more details. – Lokesh Dec 20 '18 at 08:35

2 Answers2

3

My question is - where do these default local configurations come from, and how can I change these defaults?

These are - for the most part - not defaults. This is not configuration you should change, this is a cache of information about your system.

For example, hen you create a repository, git detects whether your filesystem is case sensitive or not. It writes the core.ignorecase setting as a cache, so that it does not have to detect this again in the future, which would otherwise be a time waster for every git command.

You should not change this; it impacts how git operates with your filesystem. Again, it is not a setting with a default, it is a cache of your system’s detected behavior.

The exception to this is logallrefupdates which is indeed configuration. However, this (like any other configuration) cannot be cloned and you should find a mechanism to distribute configuration out of band (like an init script).

(But don’t change settings like core.ignorecase.)

Edward Thomson
  • 63,947
  • 11
  • 134
  • 169
  • thanks a lot, this is very helpful. The ignorecase is exactly what I wanted to change... but indeed I'm working on Windows so your answer makes sense. Any idea on how to change the cached information? – Rafael Dazcal Dec 20 '18 at 13:27
  • @RafaelDazcal: it makes little sense to change the cached information *unless* you have, for some reason, archived the `.git` directory and moved it from one computer (e.g., your Windows box) to another (e.g., your Linux box). Don't do that: use `git clone` to copy the repository. (There's another exception if you make different file systems on your machine and relocate the files across to the new file system, but again, use clone for that.) – torek Dec 20 '18 at 14:45
0

You can run this command:

git config --list --show-origin

This will give you a list of files of where each config is set globally. More detail can be found on this post

  • thanks for the reply, however I know in which file this configuration is located. What I don't know is where it is receiving its default values from – Rafael Dazcal Dec 20 '18 at 13:23