File mode with msysgit
Asked Answered
S

2

7

I cloned a Git repository from Windows using msysgit (v1.7.7) on a network drive. Some files are marked on the repository to have mode 100755.

Using the git bash tool from Windows, the ls -l command effectively shows the good permissions for those file. Now when I access the repository directory from Linux, those files have 644 permissions instead of 755.

If I chmod them to 755 on the Linux side and go back to the git bash tool on Windows:

  • the ls -l command still shows the files to have 755 permissions
  • but the git diff command tells the files changed mode from 100755 to 100644

Any idea how to properly handle file mode using msysgit on Windows?

I found this issue on msysgit which corresponds to my problem http://code.google.com/p/msysgit/issues/detail?id=164 I tried the proposed hint git update-index --chmod=+x on my files but it did not change anything.

Swine answered 30/8, 2012 at 8:41 Comment(0)
C
14

mingw doesn't support file modes as linux does. As I understand it follows windows-extension support, i.e. .exe will have +x bits. But chmod doesn't do anything.

So, for git you should specify git config core.filemode false to disable file mode support in mingw. And if you need to change it, you should do it under Linux.

Howerver, maybe I'm wrong, but afair cygwin does support file modes. You could try it instead of mingw.

Chow answered 30/8, 2012 at 9:4 Comment(1)
In cases where there is a local .git/config file that specifies filemode=true (thus overriding your global config), you can add -c core.filemode=false to your command. However, if git is being run from a script and thus affords you no control over the command-line parameters, I can't find any environment variable that can be set to accomplish the same.Iaverne
T
0

A very old question, but still relevant. I had the same issue till 5 minutes ago until it has dawned upon me - the shebang!. It is what causes the file to be executable in git-bash!

Observe:

~$ cd /tmp

/tmp$ touch 1.sh

/tmp$ ls -l 1.sh
-rw-r--r-- 1 P11F70F 1049089 0 Apr 22 12:55 1.sh

/tmp$ chmod 755 1.sh

/tmp$ ls -l 1.sh
-rw-r--r-- 1 P11F70F 1049089 0 Apr 22 12:55 1.sh

/tmp$ echo '#!/usr/bin/env bash' > 1.sh

/tmp$ ls -l 1.sh
-rwxr-xr-x 1 P11F70F 1049089 20 Apr 22 12:56 1.sh

/tmp$

chmod 755 did not help, but the file 1.sh became executable the moment I added the shebang line.

Tammara answered 22/4, 2023 at 16:57 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.