1

I have a git repository and when I create a file locally in my repo, the permissions are set to -rw-r--r--.

When i push these changes and another developer pulls these changes down, this file now has the permissions -rwxr-xr-x for him.

The same issue happens vice versa where he creates a file with permissions set to -rw-r--r-- and pushes to our git repo, then I pull the changes the permissions are now -rwxr-xr-x.

What is causing this and how can I fix it so that whatever the permissions are when one dev pushes, those same permissions will be applied when the next dev pulls?

If it matters we're using Git within TFS.

Catfish
  • 18,876
  • 54
  • 209
  • 353

2 Answers2

1

In a similar question on ServerFault (link) users harrymc and boldewyn pointed out that there are a few filesystems considered "broken" by the git team.

Those filesystems have problems with the executable bit. On those you must ignore file permission changes in order for it to work:

git config core.filemode false

That doesn't change the file permissions already stored on server. So after changing the filemode setting you might have to check how permissions arrive after you checkout the branch.

SparK
  • 5,181
  • 2
  • 23
  • 32
1

In addition to git config core.filemode false, you can set or unset the executable bit in git index, making sure git will internally record the right permission:

For instance:

find . -name '*.sh' | xargs git update-index --chmod=+x

In your case

xargs git update-index --chmod=_x -- myFile
Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250