You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

停用1Password SSH代理后Mac执行git commit报错的解决方法

解决Mac停用1Password SSH代理后git commit报错:Could not connect to socket. Is the agent running?

执行git commit时出现如下错误:

error: Could not connect to socket. Is the agent running?

fatal: failed to write commit object

问题原因

1Password作为SSH代理时,会自动修改~/.gitconfig和~/.ssh/config两个文件,强制指定使用其内置的SSH工具。停用1Password默认SSH代理后,这两个文件的配置未自动还原,导致Git无法找到正确的SSH代理和执行程序。

解决方案

手动还原这两个配置文件:

  • 编辑~/.ssh/config
    找到并移除以下配置段:

    Host *
      IdentityAgent "~/Library/Group Containers/2BUA8C4S2C.com.1password/t/agent.sock"
    
  • 编辑~/.gitconfig
    找到[gpg "ssh"]配置块,将原来的program路径:

    [gpg "ssh"]
        program = /Applications/1Password.app/Contents/MacOS/op-ssh-sign
    

    替换为系统默认的SSH路径(或你偏好的SSH执行文件路径):

    [gpg "ssh"]
        program = /usr/bin/ssh
    

该方案适用于命令行Git和GitHub Desktop客户端。

内容的提问来源于stack exchange,提问作者Ohmnitude

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.13 06:20:59