昨天在mcs上拉下一个我的git 库
在设置git hook时遇到一个问题,
明明已经给了hook文件所有的权限了,但仍然显示无权操作
hbb@huangbinbindeMacBook-Air hooks % ll
total 128
-rwxr-xr-x 1 hbb staff 478 6 18 13:34 applypatch-msg.sample
-rwxr-xr-x 1 hbb staff 896 6 18 13:34 commit-msg.sample
-rwxr-xr-x 1 hbb staff 4655 6 18 13:34 fsmonitor-watchman.sample
-rwxr-xr-x 1 hbb staff 189 6 18 13:34 post-update.sample
-rwxr-xr-x 1 hbb staff 424 6 18 13:34 pre-applypatch.sample
-rwxr-xr-x 1 hbb staff 1643 6 18 13:34 pre-commit.sample
-rwxr-xr-x 1 hbb staff 416 6 18 13:34 pre-merge-commit.sample
-rwxr-xr-x 1 hbb staff 1374 6 18 13:34 pre-push.sample
-rwxr-xr-x 1 hbb staff 4898 6 18 13:34 pre-rebase.sample
-rwxr-xr-x 1 hbb staff 544 6 18 13:34 pre-receive.sample
-rwxr-xr-x@ 1 hbb staff 1676 7 1 20:38 prepare-commit-msg
-rwxr-xr-x 1 hbb staff 1492 6 18 13:34 prepare-commit-msg.sample
-rwxr-xr-x 1 hbb staff 2783 6 18 13:34 push-to-checkout.sample
-rwxr-xr-x 1 hbb staff 3650 6 18 13:34 update.sample
hbb@huangbinbindeMacBook-Air hooks % open .
hbb@huangbinbindeMacBook-Air hooks % git commit-msg.sample
git: 'commit-msg.sample' is not a git command. See 'git --help'.
hbb@huangbinbindeMacBook-Air hooks % cd ..
hbb@huangbinbindeMacBook-Air .git % cd ..
hbb@huangbinbindeMacBook-Air prism % git commit
hint: The '.git/hooks/prepare-commit-msg' hook was ignored because it's not set as executable.
hint: You can disable this warning with `git config advice.ignoredHook false`.
文件是从windows远程连接上复制过来的,权限没问题
但仍然提示hint: The '.git/hooks/prepare-commit-msg' hook was ignored because it's not set as executable.
注意到文件名后有一个@符号,
查了一下资料,表示文件有其他元数据,应该是因为如此,导致git hook脚本执行失败了
所以查了一下去掉元数据的方式
#查询元数据
xattr -l pre-commit
#或
ls -l@ pre-commit
#删除元数据
xattr -d com.apple.quarantine pre-commit
应该是从远程桌面连接到widnows复制过来的文件被mac os标记为隔离了,用xattr -d 元数据 文件
删除这个标记就好了