Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I get Windows to leave the executable bit alone?

Tags:

git

windows

I am unfortunately forced to work on a Windows PC part of the time.

When I check out my project, git status immediately says:

modified:   bin/my_executable

git diff says:

diff --git a/bin/my_executable b/bin/my_executable
old mode 100755
new mode 100644

"oh, simple" I thought. "Windows just strips the executable bit away."

Now I've been trying to get Git to stop it for the past 30 minutes and I'm about to have a frustration provoked aneurism. Checking out the file doesn't work:

$ git checkout bin/my_executable
$ git diff
diff --git a/bin/my_executable b/bin/my_executable
old mode 100755
new mode 100644

Hard reset, no effect:

$ git reset --hard
HEAD is now at 789abcd My last commit text
$ git diff
diff --git a/bin/my_executable b/bin/my_executable
old mode 100755
new mode 100644

Switching the executable bit on using git update-index doesn't work:

$ git update-index --chmod=+x bin/my_executable
$ git diff
diff --git a/bin/my_executable b/bin/my_executable
old mode 100755
new mode 100644
$ git checkout bin/my_executable
$ git diff
diff --git a/bin/my_executable b/bin/my_executable
old mode 100755
new mode 100644

Asking Git to kindly ignore the executable bit changes didn't work:

$ git config --global core.fileMode false
$ git diff
diff --git a/bin/my_executable b/bin/my_executable
old mode 100755
new mode 100644
$ git checkout bin/my_executable
$ git diff
diff --git a/bin/my_executable b/bin/my_executable
old mode 100755
new mode 100644

This is a complete blocker. Git won't even let me pop my stash without first "committing my changes".

Can anybody help?

like image 533
Hubro Avatar asked Nov 12 '14 10:11

Hubro


1 Answers

After doing:

git config --list

I noticed that core.fileMode was set to true locally. I don't know how that happened, but it probably had something to do with the fact that the project directory is synchronized between a Windows and a Linux PC. I have used this workflow for years without this ever happening, though.

In short, this fixed my problem:

git config --unset core.fileMode

Edit: According to the comments to this answer, simply unsetting core.fileMode is no longer enough as the default value has been changed to true. I can't verify that as I no longer use Windows for development, but if that's the case you can manually set it to false instead:

git config core.fileMode false
like image 182
Hubro Avatar answered Nov 10 '22 01:11

Hubro