1

I use Git on Windows and I want to push an executable shell script into my Git repository.

Here is a related question.

However, the question and solutions are about adding execute permission to everyone, effectively chmod ugo+x. I want to do chmod u+x.

ChrisGPT was on strike
  • 127,765
  • 105
  • 273
  • 257
netok
  • 181
  • 3
  • 9
  • What have you tried? Why is it not working? – Kalle Richter Jul 18 '18 at 01:37
  • @KarlRichter It is not working because `git update-index` can only do that. – netok Jul 18 '18 at 01:42
  • People who downvote my question, please leave your comment here and explain why. Thanks. – netok Jul 18 '18 at 01:48
  • Welcome to StackOverflow! To help others answer your question better (and to avoid downvotes), please try to provide as many details as possible explaining your problem and why solutions you have tried haven't worked. I'd recommend reading [How to Ask](https://stackoverflow.com/help/how-to-ask) for more information. – ricky3350 Jul 18 '18 at 03:16

1 Answers1

2

The only permissions that Git tracks (regardless of operating system) is the executable bit. This is by design:

Actually in a very early days, git used to record the full (mode & 0777) for blobs.

Once people started using git, everybody realized that it had a very unpleasant side effect that the resulting tree depended on user's umasks, because one person records a blob with mode 664 and the next person who modifies the file would record with mode 644, and it made it very hard to keep track of meaningful changes to the source code. This issue was fixed long time ago with commit e447947 (Be much more liberal about the file mode bits., 2005-04-16).

Note that Junio Hamano, the author of the quoted post, has been the main Git maintainer since 2005, shortly after it was created.

Granular execute permissions are best applied on deployment.

ChrisGPT was on strike
  • 127,765
  • 105
  • 273
  • 257