سؤال

From the threads that I have read, git should set 644 by design, which is what I want. However, whenever I git pull my repository, it changes the permissions to 664.

My local disk has permissions set as 644 (what I want). If I upload via FTP and Filezilla, these permissions are retained on the server.

Why are my permissions changing, and is there a way to fix it without manually changing permissions?

هل كانت مفيدة؟

المحلول

You need to distinguish between the permissions that are stored in the git repository and the permissions on the files in your working copy. The whole point of that other question you linked to is that these 2 things are different because git doesn't preserve permissions.

When you commit something, git remembers whether it was executable or not, and nothing else. When you check out a file, you get file permissions decided by your umask.

Umask is a process attribute containing permission bits that are removed from newly created files. Git creates directories and executable files with mode 777, and non-executable files with 666, and your umask turns off some of those bits. If you want default permissions to be 644 and 755, you set your umask to 022:

umask 022

I keep mine at 077 - all files private until explicitly made otherwise. Because of git's policy of not preserving permissions, we can both pull from the same repository and get our preferred defaults on the checked-out files.

Your preferred umask is a good candidate for inclusion in a shell startup file (.profile, .zsh*, .bash*, etc.)

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top