git ignore filemode config isn't working

2019-04-12 06:24发布

问题:

I am using gitolite git server on a ubuntu linux server. I used a hook that will be called on every push and will update a server's directory(which include live site's source code).

Now, whenever I change something on my local pc and push the changes to server, the hook is being called and the pull request are being executed fine. But, problem is, the files which were updated, are now having changed permission. Like:

rwxrwxr_x (before)
rwx_____x (After)

After few searches, I did came up with this solution . I did tried it with both my global git config and repository specific config settings. after setting the config, whenever I am trying to push from my local pc, the same issue is happening again like above, thus seems, for some reason, the solution isn't working.

Does anybody have any idea, what can be the reason plz? Do I have to do anything additionally besides the config settings? Any suggestions are welcome. Thanks in advance.

回答1:

As the OP Rana confirms in the comments, if the hook starts with:

umask 002

It will generate files with the right protection.


Alan Thompson mentions:

core.filemode only affects diffs against your working dir, not diffs between 2 commits in the repo.
So, if you have already committed the different file modes, you'll have to use filter-branch, as in "Can I make git diff ignore permission changes".

git filter-branch -f --tree-filter 'find * -type f | xargs chmod 644 ' -- --all