In git bash for windows 10 when I do:
$ ls -la
-rw-r--r-- 1 user 1049089 10 Jul 23 19:00 .gitignore
-rwxr-xr-x 1 user 1049089 28 Sep 19 15:47 a.sh*
-rwxr-xr-x 1 user 1049089 28 Sep 19 15:47 b.sh*
I can see that both a.sh
and b.sh
are executable. Also I have verified that by running both scripts - so from my filesystem point of view both of those files are executable.
But when I do:
$ git ls-tree HEAD
100644 blob c91cb20899da1dc6da1752f8b9cdc59e58e50873 a.sh
100755 blob c91cb20899da1dc6da1752f8b9cdc59e58e50873 b.sh
So from git perspective only b.sh
is executable which is also the case when I clone my repository on jenkins an try to execute the two scripts (only b.sh
is getting executed).
I have tried to: chmod +x a.sh
but git does not pick that up and just returns a status saying nothing to commit or nothing has been modified.
What is going on and how do I fix this?
UPDATE:
I now have:
$ git config -l | grep core
core.symlinks=true
core.autocrlf=false
core.fscache=true
core.editor='C:\Program Files (x86)\Notepad++\notepad++.exe' -multiInst -notabbar -nosession -noPlugin
core.editor='C:/Program Files (x86)/Notepad++/notepad++.exe' -multiInst -nosession
core.autocrlf=false
core.preloadindex=true
core.fscache=true
core.filemode=true
Which makes sense since I have added core.filemode=true
in C:\Users\user\.gitconfig
:
...
[core]
editor = 'C:/Program Files (x86)/Notepad++/notepad++.exe' -multiInst -nosession
autocrlf = false
preloadindex = true
fscache = true
fileMode = true
...
But when I clone a new repository and run the same again from inside the repository I get:
$ git clone ssh://git@host/my-repo.git
..
$ cd my-repo
$ git config -l | grep core
core.symlinks=true
core.autocrlf=false
core.fscache=true
core.editor='C:\Program Files (x86)\Notepad++\notepad++.exe' -multiInst -notabbar -nosession -noPlugin
core.editor='C:/Program Files (x86)/Notepad++/notepad++.exe' -multiInst -nosession
core.autocrlf=false
core.preloadindex=true
core.fscache=true
core.filemode=true
core.repositoryformatversion=0
core.filemode=false
core.bare=false
core.logallrefupdates=true
core.ignorecase=true
So it now lists two entries for core.filemode
. First one I guess is from the .gitconfig file from my user folder and the second one (set to false) seems to come from the file my-repo/.git/config
that contains:
[core]
repositoryformatversion = 0
filemode = false
bare = false
logallrefupdates = true
ignorecase = true
[remote "origin"]
What determines what gets set in my-repo/.git/config
and why is that set to false?
Based on:
Git global core.fileMode false overridden locally on clone
and:
it seem I need to manully change .git/config after a clone for it to have any effect.