Git ignoring gitconfig?

It appears Git is ignoring ~/.gitconfig

$ git config --global core.filemode false

$ git config -l
core.filemode=false
core.filemode=true

So now there are 2 entries for core.filemode and git is still not ignoring filemode changes

$ touch modetest

$ git add .

$ git commit -m test1
[master (root-commit) 320cfe4] test1
 0 files changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 modetest

$ chmod +x modetest

$ git diff
diff --git a/modetest b/modetest
old mode 100644
new mode 100755

Based on torek’s answer, I added this line to my .bash_profile

[ -d .git ] && git config core.filemode false

  • How to set a version dependent Git global config flag
  • what's the difference between `` and `` in a gitconfig file?
  • git rebase could not execute editor
  • “git init” failed, what's wrong?
  • GIT over HTTP configure auth username. credential.username not working?
  • GIT warning: too many files skipping inexact rename detection
  • Pre-determine default Git Local config values
  • commit inside git submodule foreach
  • 3 Solutions collect form web for “Git ignoring gitconfig?”

    Maybe a bit overkill, but in Cygwin this bothered me enough to dig into the issue more. When git is built from source code, it checks the file system it’s built on to see if it understands executable bits.

    I went ahead and built git from source on my Cygwin system and installed it to a local directory, then added the binary to my path. The basic steps are:

    cd ~/
    mkdir git
    cd git
    mkdir inst
    git clone -c core.autocrlf=false https://github.com/git/git.git
    cd git
    NO_TRUSTABLE_FILEMODE=1 make prefix=/home/[username]/git/inst/
    NO_TRUSTABLE_FILEMODE=1 make prefix=/home/[username]/git/inst/ install
    

    Then add something like this to .bashrc:

    export PATH=/home/[username]/git/inst/bin:$PATH
    

    Of course, that build won’t work unless you have all the build dependencies installed in Cygwin. With a little poking around I was able to do it without too much trouble. Now git init and git clone on that system defaults filemode to false. The trick is defining NO_TRUSTABLE_FILEMODE for the build.

    When creating or reinitializing a new repo, git init always sets a new value
    for core.filemode based on the result of probing the file system. You’ll just
    have to manually:

    git config core.filemode false
    

    Or:

    git config --unset core.filemode
    

    to make it respect the one in your ~/.gitconfig. If you run git init again
    the per-repo setting will go back to true on your system.

    (EDIT) so to resume, on windows we need to do :

    git config --global --unset core.filemode
    git config --unset core.filemode
    git config core.filemode false
    

    And you can create an empty config file in Git install dir for new git folders (init) :

    C:\bin\Git\share\git-core\templates>echo > config
    C:\bin\Git\share\git-core\templates>notepad config
    

    And put inside :

    [core]
    filemode = false
    
    Git Baby is a git and github fan, let's start git clone.