Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
2.0k views
in Technique[技术] by (71.8m points)

why my file permission being changed after pull from git repository

I have been came across this problem over and over again. I have a git repository set up on my remote server and all the files are set to 644 and folders are set to 755. However, every time after i pulling from git repository(i'm using bitbucket), i noticed the permission of the file which i modified was changed into 664 which results a Internal server Error. For example, I changed the index.php, and it occurs 500 when i tried to get access to it

i have to use find . -type d -print0 | xargs -0 chmod 0755 and find . -type f -print0 | xargs -0 chmod 0644 to manually changed my files permission back to normal

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

As described in "Git set create mode to 100664 when pushing new folder/files to shared repo":

git doesn't store file permissions at the level you want. Having 644 or 664 files depends purely on umask."

(022 in your case, as commented by Jan Hudec

Git only stores two permissions (755=rwxr.xr.x, 644=rw.r..r..).

git simply doesn't track permissions.
In fact, it refuses to. Turns out there are enough mutually-exclusive definitions of how to do it right, all of which can be whipped up with simple scripting, that the simple scripting is the right way to implement it.
Plus, those rules are best left per-repo, because there's repo purpose and host OS to consider.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
...