1

I need to set the permission of script.sh to 755. So

git add -A
git update-index --chmod=+x script.sh
git commit -m 'first commit'

This way the file will be committed with a permission 755 and my remote vm can execute those scripts.

However, next time I do something to the repo and commit the changes the permission of those scripts will be reverted to 644. The message is

[master 171c0cc] second
 2 files changed, 1 insertion(+)
 mode change 100755 => 100644 script.sh

Anyone know what might be happening here? How do I get rid of this?

Zombo
  • 1
  • 62
  • 391
  • 407
Shih-Min Lee
  • 9,350
  • 7
  • 37
  • 67

1 Answers1

1

First check your git config core.fileMode: if it is set to false, the executable bit of files in the working tree won't be honored anyway.

If it is true or not set, then try a chmod.

Then try also to set core.sharedRepository to group.
And check your umask. umask 002 in your case should work.

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • right now `core.fileMode` is true. umask is 002. I updated file mode to 755 and committed the changes. But next time I do `git add -A` all the file modes changed back to 644. – Shih-Min Lee Oct 26 '15 at 07:40
  • Would core.shared repository (that I mentioned in the answer) would change anything? – VonC Oct 26 '15 at 08:08
  • I set `core.shareRepository` to `group` as you suggested but the results seem to be the same. – Shih-Min Lee Oct 26 '15 at 08:47
  • Make sure you have used core.sharedRepository, not share: shared – VonC Oct 26 '15 at 09:41
  • I think I know what's happening. I have to do `chmod 755` from the shell so future git commits will be based on the actual file mode. Otherwise `git update-index --chmod=+x` is an one time thing and the file modes will revert back to 644 on next commit for some reason. – Shih-Min Lee Oct 27 '15 at 02:43