在任何地方都找不到答案,但最终找出了问题并想分享解决方案。
问题:使用 1Password ssh 代理后,尝试git commit通过 Mac 上的终端进行连接会产生以下错误:
error: Could not connect to socket. Is the agent running?
fatal: failed to write commit object
Run Code Online (Sandbox Code Playgroud)
解决方案:1Password修改两个文件,其中指定使用哪个ssh;~/.gitconfig和~/.ssh/config。删除 1Password 作为默认 ssh 代理后,这两个文件也必须恢复:
在 中~/.ssh/config,删除此内容:
Host *
IdentityAgent "~/Library/Group Containers/2BUA8C4S2C.com.1password/t/agent.sock"
Run Code Online (Sandbox Code Playgroud)
在你的 中~/.gitconfig,替换它:
[gpg "ssh"]
program = /Applications/1Password.app/Contents/MacOS/op-ssh-sign
Run Code Online (Sandbox Code Playgroud)
通过这条路径到达您喜欢的任何地方ssh(可能/usr/bin/ssh):
[gpg "ssh"]
program = /usr/bin/ssh
Run Code Online (Sandbox Code Playgroud)
此解决方案适用于命令行 git 和 GitHub Desktop 客户端。