1

In the following we see that Git set ignorecase to true by default despite my .gitconfig configuration.

$ mkdir foo && cd foo && git init Initialized empty Git repository in /cygdrive/c/Users/nowox/home/git/foo/.git/ $ cat .git/config | grep ignore ignorecase = true 

How can I tell Git to set ignorecase to false by default for new repositories?

I have put this config file in $GIT_TEMPLATE_DIR (/usr/share/git-core/templates):

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

But it still doesn't work. It seems my config file is erased by Git...

Full Example

~/test $ git init Initialized empty Git repository in /cygdrive/c/test/.git/ ~/test $ cat .git/config [core] ignorecase = true repositoryformatversion = 0 filemode = true bare = false logallrefupdates = true ~/test $ cat /usr/share/git-core/templates/config [core] ignorecase = false repositoryformatversion = 0 filemode = true bare = false logallrefupdates = true 

It looks it doesn't work. Both config files are different:

~/test $ diff /usr/share/git-core/templates/config .git/config 2,5c2,5 < ignorecase = false < repositoryformatversion = 0 < filemode = true < bare = false --- > ignorecase = true > repositoryformatversion = 0 > filemode = true > bare = false 

It is the same if I declare the GIT_TEMPLATE_DIR variable:

~/test $ rm -rf .git ~/test $ GIT_TEMPLATE_DIR=/usr/share/git-core/templates git init . Initialized empty Git repository in /cygdrive/test/.git/ ~/test $ cat .git/config [core] ignorecase = true repositoryformatversion = 0 filemode = true bare = false logallrefupdates = true 
1
  • 1
    By the way, git init foo && cd $_. $_ expands to the last parameter to the previous command. Commented Jul 28, 2017 at 15:38

1 Answer 1

1

See TEMPLATE DIRECTORY of git-init.

By default, when we initialize a new git repo, the contents under /usr/share/git-core/templates will be copied to this new repo's .git. So we can make a template for config here, which includes

[core] ignoreCase = false 

For git-bash-for-windows, it's /mingw64/share/git-core/templates/ or /mingw32/share/git-core/templates/.

Besides as the manual says, we have the folloing options to specify the templates.

  1. the argument given with the --template option;
  2. the contents of the $GIT_TEMPLATE_DIR environment variable;
  3. the init.templateDir configuration variable.
Sign up to request clarification or add additional context in comments.

8 Comments

This does not answer the question. A file named config added on the template directory will be clobbered by Git during the git init.
@nowox Is your $GIT_TEMPLATE_DIR or init.templateDir set to the value different from /usr/share/git-core/templates?
No it points to usr/share/git-core/templates and I have added a config file in this template dir with the ignoreCase set to false
@nowox It should have worked. I've tested on both Windows and Ubuntu and it works as expected. What is .git/config like in your failed case?
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.