微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Git提交的权限被拒绝,但可以使用--no-verify

如何解决Git提交的权限被拒绝,但可以使用--no-verify

我跑步时,git commit -m 'Test'收到此消息:

[INFO] Initializing environment for git@github.com:humitos/mirrors-autoflake.git.
An unexpected error has occurred: CalledProcessError: command: ('/usr/local/git/libexec/git-core/git','fetch','origin','--tags')
return code: 128
expected return code: 0
stdout: (none)
stderr:
    git@github.com: Permission denied (publickey).
    fatal: Could not read from remote repository.

    Please make sure you have the correct access rights
    and the repository exists.

Check the log at /Users/amit/.cache/pre-commit/pre-commit.log

但是如果运行git commit -m 'Test' --no-verify,它可以正常工作。我的预提交钩有问题,有什么想法吗?

解决方法

您的.pre-commit-config.yaml文件似乎使用ssh url引用了git存储库,但是您没有为github配置的ssh密钥

您可以用repo: git@github.com:humitos/mirrors-autoflake安全地替换对repo: https://github.com/humitos/mirrors-autoflake的引用(特别是因为这是一个公共存储库)

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。