0

I have set a couple global configs in git:

git config --global core.autocrlf true
git config --global core.filemode false

These show up in my ~/.gitconfig file:

[core]
    editor = vim
    autocrlf = true
    fileMode = false

however, my repositories continue to check filemodes and continue to commit Windows line endings. I have to execute the git config command within each repository or the configs don't get loaded.

What's happening?

ewok
  • 20,148
  • 51
  • 149
  • 254

1 Answers1

2

Do you have overrides in your local git repo config file?

If you cd to your repository and run:

$ cat .git/config

Are there any settings in there with the same keys but different globals to your global presets?

Edit:

I slightly misunderstood the way git works. It will look in the local config file and if it doesn't exist, fall back to the global one.

Based on the conversation below, it appears having fileMode set to true is baked into the Git core.

I would suggest making an alias (or two):

[alias]
    create = init && git config core.fileMode false
Community
  • 1
  • 1
mikestreety
  • 833
  • 6
  • 28
  • ok, that's why. Thanks. but it leads me to another question. the `.git` folder is ignored by `.gitignore`, so it isn't getting those configs from the repo. why are they defaulting to the values I don't want when I clone the repo, and how can I fix that? – ewok Oct 21 '16 at 14:41
  • Hmm odd, when you initialise a new repo or clone, it should take the settings from your global file and put them in the local file. Does it even do it if you do a fresh clone of a repo? What about if you run `git init` then view that config file? – mikestreety Oct 21 '16 at 14:44
  • when I execute `git init` I get a config file that has `filemode` set to `true` and no value for `autocrlf`. Now that I look again, none of the repos have `autocrlf` set, but I also notice that the line endings arent actually getting committed, so that one isn't a problem. `filemode` is still strange though – ewok Oct 21 '16 at 14:48
  • I've misunderstood git and your question. I've done some digging and the `gitconfig` is only used if local settings don't exist (in the example of your `autocrlf`). However, I'm looking into how you change the global setting – mikestreety Oct 21 '16 at 16:24
  • So we can forget about `autocrlf`. I was misinterpreting the behavior. What I'm confused about is why `filemode` is being initialized to true when the global setting is false. – ewok Oct 21 '16 at 16:25
  • 1
    Looks like it's hard coded and you'll have to do it on a per repo basis - http://stackoverflow.com/questions/2093077/default-config-settings-for-a-new-git-repository#comment65325465_2093395 - I have updated my answer above – mikestreety Oct 21 '16 at 16:35