Robert Sinclair
Robert Sinclair

Reputation: 5416

git config core.filemode false not working git 2.25.1

I read this solution How do I make Git ignore file mode (chmod) changes? and tried a number of other things but the following keeps happening:

When I do

git status -v

It shows

diff --git a/video.html b/video.html
old mode 100644
new mode 100755

So it's picking up changes in file permissions, but when I run the following command to make it ignore file changes

git config core.filemode false

It still sees the changes. Am I doing something wrong or misunderstanding how filemode works?

I also tried changing global git settings, modifying the .git/config file etc to set filemode to false but nothing works, it still sees the changes.

Manual permission change via git update-index

The only workaround I found for now is by going to repo folder and doing something like git update-index --chmod=-x FILENAME with a recursive approach

git ls-files --stage | grep 100755 | cut -f2 | xargs git update-index --chmod=-x

But this does not cover all of the files unfortunately

"Solution"

In the end had to do a hard reset from master to fix the issue. Think the problem was that I committed that files with changed permissions BEFORE doing the git config core.filemode false and once committed I'm assuming it was somewhere in git cache and there was no way to ignore the permissions with any sort of filemode change.

Upvotes: 1

Views: 2118

Answers (1)

torek
torek

Reputation: 488453

Update: the question is modified now; here's what I think the real answer is:

  • Your file system doesn't actually support modes.
  • You did actually set core.filemode to true at some point.
  • This made Git believe the results from the lstat call. That updated a bunch of index entries to have mode 100755 (probably).
  • This in turn had Git make a commit with the wrong modes in it.
  • After that, you fixed core.filemode (put it back to false) and perhaps updated Git's index as well (note that Git's index retains any +x or -x setting that gets set in it, whether that comes from trusting-lstat-and-seeing-x-bits-in-the-working-tree, or from git update-index --chmod, or whatever, until some other operation comes along and updates Git's index).

Once things get messy, the fix tends to be messy too.

Original answer below.


git config core.filemode means git config --get core.filemode, i.e., tell me what core.filemode is set to. It will not change the setting.

As noted in the accepted answer to the question you linked to, the command to set it is:

git config core.filemode false

(you can spell core.filemode with partial or full uppercase if you like; this particular bit of Git is case-insensitive). In general, however, you should never set core.filemode at all. Having to do so indicates that something else on your system is misbehaving. You should fix the other thing instead.

Upvotes: 1

Related Questions