git忽略filemode配置不起作用 [英] git ignore filemode config isn't working

查看:301
本文介绍了git忽略filemode配置不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Ubuntu的linux服务器上使用gitolite git服务器。我使用了一个将在每次推送时调用的钩子,并将更新服务器的目录(其中包括活动网站的源代码)。

现在,每当我在本地pc并将更改推送到服务器,钩子正在调用并且正在执行拉取请求。但问题是,更新的文件现在已经改变了权限。喜欢:

  rwxrwxr_x(之前)
rwx_____x(之后)

经过几次搜索,我确实想出了这个解决方案。我确实用了我的全局git配置和存储库特定的配置设置。设置配置后,每当我试图从我的本地电脑推,同样的问题再次发生,如上所述,因此出于某种原因,该解决方案似乎无法正常工作。



有没有人有任何想法,可能是什么原因PLZ?除了配置设置之外,我还需要做些什么吗?欢迎任何建议。提前致谢。

解决方案

正如 OP Rana 确认在评论中,如果挂钩启动与:

  umask 002 

它会生成具有正确保护的文件。






艾伦汤普森提到:


core.filemode 只会影响你的工作目录的差异,不能区分repo中的两次提交。

因此,如果你已经提交了不同的文件模式,你将会拥有使用 filter-branch ,如我可以让git diff忽略权限更改




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


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.

解决方案

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

这篇关于git忽略filemode配置不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆