4

I am developing a website on my windows laptop, and I use Git for the version control.

When I add my files to Git, they are added under the mode 644. The problem is, on my Linux server, I need the files to be 775. So what I do is, every time I deploy, I have to run chmod 775 -R . on my linux server and then commit the mode changes.

This is really anoying, time consuming, and result in lot of stranges commits.

My question is, how can I make my IDE (PHPStorm) create the files direcly with mode 775? I know Windows does not use the same file permission system as UNIX, but there must be a way to set the files permissions on windows that translates to 775 in Linux?

I tried to use "chmod" command on windows using Cygwin or similar tools, with no luck, Git always saves the files as 644 when I commit on windows.

Cœur
  • 37,241
  • 25
  • 195
  • 267
Paulin Trognon
  • 762
  • 6
  • 17
  • In theory you could create either a *pre-commit* hook which uses `git update-index --chmod` as jas_raj suggested. Alternativly you could use a post-recieve hook on the serverside to update your file permissions as you see fit. – Sascha Wolf Oct 23 '14 at 12:42

1 Answers1

3

See: Updating file permissions only in git

In summary, git update-index --chmod should do what you need.

Community
  • 1
  • 1
jas_raj
  • 1,131
  • 6
  • 14
  • Well, I want 775, not 755, so I don't think that's helping me that much? And I tried it, after this command, git still commit my windows files as 644... – Paulin Trognon Oct 27 '14 at 15:17
  • --chmod will only change the user execute permission, it doesn't look like it supports changing group or other. However it will ensure the file keeps the user execute permission - I tested committing a file on Windows, update the permission and then checking out on Linux. Seems to work here. – jas_raj Oct 28 '14 at 14:21
  • You updating the permission on windows using what tool? – Paulin Trognon Oct 28 '14 at 15:23