I have a committed file on git that currently has permissions 755, but I need it to only have 700. I was wondering if anybody has had experience with this? I was hoping a git bash command existed to simply let me say the exact permissions, but it doesn't seem as so.
What is a bit bothersome as well is I have this file as 700 on my local directory, but it has become 755 when it went onto our Azure DevOps git repo.
CodePudding user response:
Git only stores two types of permissions for plain files: 644 and 755. That is, it cares only about the executable bit. There is no way to force a specific set of permissions other than those two types.
If you want the file to have different permissions in the working tree, you can set core.sharedRepository
to 0600
, which will make files have either 0600 or 0700 permissions, or you can fix it up after the fact with a post-checkout
hook or a script. However, none of these are automatic, since Git does not allow pushing configuration or hooks to users, so each user will have to set this appropriately.