1

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:

Git ignoring gitconfig?

it seem I need to manully change .git/config after a clone for it to have any effect.

u123
  • 15,603
  • 58
  • 186
  • 303
  • I don't have time to read through it right now, but it looks like this might be helpful https://medium.com/@tahteche/how-git-treats-changes-in-file-permissions-f71874ca239d – scatter Sep 19 '19 at 14:25
  • A few ideas from https://stackoverflow.com/q/1580596/7976758: what is your `git config core.fileMode`? Try `git diff --summary | grep 'mode change`. Try `git update-index --chmod=+x a.sh`. See https://stackoverflow.com/search?q=%5Bgit%5D+update+executable – phd Sep 19 '19 at 14:35

1 Answers1

1

You set the core.fileMode to true on Windows so git will track the execution bit

# tell git to keep/ignore filemode (chmod) as change,
git config core.fileMode true/false

core.fileMode
Tells Git if the executable bit of files in the working tree is to be honored.
The default is true (when core.filemode is not specified in the config file).


How to update executable bit? (as you already did)

# If you wish to set the executable bit use this command
git update-index --chmod=+x <file>

--chmod=(+|-)x Set the execute permissions on the updated files.

Community
  • 1
  • 1
CodeWizard
  • 128,036
  • 21
  • 144
  • 167
  • See my updated post, it seem that core.fileMode is forced to false in the local gitconfig file for some reason. – u123 Sep 19 '19 at 19:03