[英]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.