Reputation: 14311
I'm having problems setting permissions on files with git. I'd like to make all files in the repository 644. When I first clone
the repo, the files are a mix of different permissions:
-rw------- 1 username group 2305 Oct 25 15:16 addquotes.sas
-rw------- 1 username group 675 Oct 25 15:16 ama_permission.sas
-rw------- 1 username group 1581 Oct 25 15:16 append_words.sas
-rwx------ 1 username group 3688 Oct 25 15:16 sasv9_u8.cfg
-rwx------ 1 username group 1489 Oct 25 15:16 backtest/bt_means.sas
-rwx------ 1 username group 490 Oct 25 15:16 backtest/correct_vname.sas
-rwx------ 1 username group 838 Oct 25 15:16 backtest/gen_random_samples.sas
To attempt to fix this, I run find . -type f | xargs chmod 644
. This changes the permissions on the file system, but only a few appear as modified when I do a git status
:
modified: sasv9_u8.cfg
modified: backtest/bt_means.sas
modified: backtest/correct_vname.sas
modified: backtest/gen_random_samples.sas
Digging deeper, I noticed that the files showing as modified had the owner execute bit set. If I run find . -type f | xargs chmod 744
(744
vs 644
, to set the owner execute bit), then all the files appear in the git status
command.
Is there any way to get git to recognize the permission without setting the execute bit on the owner? This behavior seems odd.
Upvotes: 0
Views: 129
Reputation: 51780
Two points worth mentioning :
git
does not store the whole range of unix permissions on files : it only stores "regular files" and "executable files",git
behaves like a normal process, and doesn't try to go around your umask ; the reason why you see no access rights for the group
or other
part is probably because your umask is set to 0077
A "regular file" will be checked out as -rw-rw-rw-
-- minus your umask ; an "executable file" will be checked out as -rwxrwxrwx
-- again, minus your umask.
About what you see :
0077
(no rights for group
and other
), so the "regular files" get checked out as -rw-------
and "executable files" as -rwx------
chmod 644
on your files, git
detects that files that were previously executable are not executable anymore, and these ones show up,chmod 744
makes git
detect a change on "executable" files : on my machine, it looks like git
only checks for the (linux) executable flag set for user
to determine if a file should be stored as executable ; detecting a change on "regular files" is expected.How to "fix" this :
X
option of chmod, which will set the executable flag only if at least one executable flag is set :# you seem to want to give rw (and possibly x) access to the group :
chmod -R g+rwX *
# perhaps r (and possibly x) to "others" :
chmod -R o+rX *
Upvotes: 5