简体   繁体   English

每次我启动git-bash时都需要发出ssh-agent命令

[英]Need to issue ssh-agent command every time I start git-bash

I'm using Windows 7. My company has some repos stored on our own git server. 我使用的是Windows7。我的公司在我们自己的git服务器上存储了一些存储库。 Recently I also had to use GitHub, but ever since I've accessed the repo that's on GitHub, git-bash has been acting really wonky. 最近,我也不得不使用GitHub,但是自从我访问了GitHub上的存储库以来,git-bash一直表现得很糟糕。

What it all boils down to is that every time I open git-bash, if I try do a pull, I get: "error: cannot span git: No such file or directory." 归结为,每次我打开git-bash时,如果我尝试进行拉取,都会得到:“错误:无法跨越git:没有这样的文件或目录。”

My git version is 2.18.0.windows.1 我的git版本是2.18.0.windows.1

I've found that I manually have to execute this command every time I launch git-bash: 我发现每次启动git-bash时都必须手动执行以下命令:

eval $(ssh-agent)

I've tried using the info here: Start ssh-agent on login 我尝试在这里使用信息: 登录时启动ssh-agent

And here: https://help.github.com/articles/working-with-ssh-key-passphrases/#auto-launching-ssh-agent-on-git-for-windows 此处: https : //help.github.com/articles/working-with-ssh-key-passphrases/#auto-launching-ssh-agent-on-git-for-windows

My .profile consists of the following: 我的.profile包含以下内容:

env=~/.ssh/agent.env

agent_load_env () { test -f "$env" && . "$env" >| /dev/null ; }

agent_start () {
    (umask 077; ssh-agent >| "$env")
    . "$env" >| /dev/null ; }

agent_load_env

# agent_run_state: 0=agent running w/ key; 1=agent w/o key; 2= agent not running
agent_run_state=$(ssh-add -l >| /dev/null 2>&1; echo $?)

if [ ! "$SSH_AUTH_SOCK" ] || [ $agent_run_state = 2 ]; then
    agent_start
    ssh-add
elif [ "$SSH_AUTH_SOCK" ] && [ $agent_run_state = 1 ]; then
    ssh-add
fi

unset env

But nope...I still need to manually execute that command whenever I start git -bash. 但是不,...我每次启动git -bash时仍需要手动执行该命令。 (And the above code is supposed to quash that necessity.) (上面的代码应该消除了这种必要性。)

Both of those links suggests adding that in .bash_profile or .bashrc (see " What are the functional differences between .profile .bash_profile and .bashrc ") 这两个链接都建议在.bash_profile.bashrc添加(请参阅“ .profile .bash_profile.bashrc之间的功能区别是什么 ”)

Try that first, instead of using .profile . 首先尝试,而不要使用.profile

Make sure your git bash does echo $HOME to the expected value: set HOME first to %USERPROFILE% . 确保您的git bash确实将echo $HOME到期望的值:首先set HOME%USERPROFILE%

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在 VS Code 中使用 Windows 内置的 OpenSSH ssh-agent,而不是 Git bash? - How can I use Windows' built-in OpenSSH ssh-agent in VS Code, instead of Git bash's? sh脚本不会将ssh密钥添加到ssh-agent(windows git bash) - sh script doesn't add ssh key to ssh-agent (windows git bash) git-bash中的curl命令 - curl command in git-bash git-bash:ssh:重新开始,传递了另一个列表publickey,password - Git-bash : ssh: start over, passed a different list publickey,password 使用 cygwin ssh-agent 正在运行,但 git 仍在提示输入密码 - Using cygwin ssh-agent is running but git is still prompting for passphrase 启动 Pageant SSH-Agent 并将所有密钥加载到一个文件夹中 - Start Pageant SSH-Agent and load all keys in a folder 无法在 Windows 10 上使用 Git Bash 启动 SSH 代理 - Can't start SSH Agent with Git Bash on Windows 10 在使用本机 OpenSSH 的 ssh-agent 配置良好的 Windows 10 上,如何使用配置的 ssh-agent 实现 git? - On Windows 10 that is well configured with native OpenSSH's ssh-agent, how to have an implementation of git use the ssh-agent configured? 如何使用名称启动git-bash中的Windows进程 - How to start a windows process in git-bash with a name 通过 Git-Bash 使用包含空格的“cmd”执行命令? - Executing Command with "cmd" That Contains Spaces Through Git-Bash?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM