4

I have installed cygwin (and git using the cygwin package manager) and git bash for windows.

I have just cloned a repository using cygwin shell and then opened a git bash shell and a cygwin shell in the root of the repository.

Then I execute git status from each shell. Git bash finds a change (file permission) but cygwin does NOT and I am trying to understand why.

Below are the details:

Git Bash (show modified file)

$ git --version
git version 2.23.0.windows.1
$ git status
On branch master
Your branch is up to date with 'origin/master'.

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

        modified:   script.sh

no changes added to commit (use "git add" and/or "git commit -a")

$ git diff
diff --git a/script.sh b/script.sh
old mode 100755
new mode 100644

$ 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=true
core.bare=false
core.logallrefupdates=true
core.ignorecase=true

Cygwin (no changes found)

$ git --version
git version 2.21.0
$ git status
On branch master
Your branch is up to date with 'origin/master'.

nothing to commit, working tree clean

$ git config -l | grep core
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=true
core.bare=false
core.logallrefupdates=true
core.ignorecase=true

So for both shells core.filemode=true.

Any suggestions to why git bash picks up the file permission change?

u123
  • 15,603
  • 58
  • 186
  • 303

2 Answers2

2

Try:

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

If that resolves the problem, than line ending settings were the problem.

In case the changes are reported as typechange, then the problem might be the simlinks, and the solution:

git config core.symlinks true

Also, make sure to apply those settings locally in the mentioned repo, not just globally.

Danijel
  • 8,198
  • 18
  • 69
  • 133
-1

Issue this command

git config core.fileMode false

in both repos.

See How do I make Git ignore file mode (chmod) changes?

Doug Henderson
  • 785
  • 8
  • 17
  • But I don't want git to ignore chmod changes - also it does not really answer my question of why the difference. – u123 Sep 21 '19 at 06:26
  • 2
    Windows and POSIX filemodes are not symmetrical. The Window model has a much finer granularity than the POSIX user/group/other X read/write/execute model. Notice that an `ls -l` shows a + after the rwx bits which indicates there are more ACLs in effect than can be shown by the POSIX model. – Doug Henderson Sep 21 '19 at 09:34