u123
u123

Reputation: 16287

Git status gives different results in cygwin and git bash (windows 10)

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?

Upvotes: 4

Views: 822

Answers (2)

Danijel
Danijel

Reputation: 8616

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.

Upvotes: 3

Doug Henderson
Doug Henderson

Reputation: 888

Issue this command

git config core.fileMode false

in both repos.

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

Upvotes: -1

Related Questions