1

我已经在 bitbucket 中设置了一个帐户。按照这里给出的步骤, https://confluence.atlassian.com/display/BITBUCKET/Set+up+SSH+for+Git

在步骤 6.5 中,当我重新打开 gitbash 时,出现以下错误,

Welcome to Git (version 1.8.1.2-preview20130201)


Run 'git help git' to display the help index.
Run 'git help <command>' to display help for specific commands.
sh.exe": /c/Documents: No such file or directory
Usage: grep [OPTION]... PATTERN [FILE]...
Try `grep --help' for more information.
Initializing new SSH agent...
sh.exe": ${SSH_ENV}: ambiguous redirect
succeeded
chmod: getting attributes of `/c/Documents': No such file or directory
chmod: getting attributes of `and': No such file or directory
chmod: getting attributes of `Settings/vyc/.ssh/environment': No such file or
directory
sh.exe": /c/Documents: No such file or directory
Could not open a connection to your authentication agent.

我猜它是 dir 路径中的空间问题,但不知道如何解决它..

4

3 回答 3

4

您是正确的,因为这是 dir 路径中的空间问题。修复它的方法是打开 .bashrc 文件并用引号将 ${SSH_ENV} 括起来,如下代码所示:

SSH_ENV=$HOME/.ssh/environment

# start the ssh-agent
function start_agent {
    echo "Initializing new SSH agent..."
    # spawn ssh-agent
    /usr/bin/ssh-agent | sed 's/^echo/#echo/' > "${SSH_ENV}"
    echo succeeded
    chmod 600 "${SSH_ENV}"
    . "${SSH_ENV}" > /dev/null
    /usr/bin/ssh-add
}

if [ -f "${SSH_ENV}" ]; then
     . "${SSH_ENV}" > /dev/null
     ps -ef | grep ${SSH_AGENT_PID} | grep ssh-agent$ > /dev/null || {
        start_agent;
    }
else
    start_agent;
fi
于 2013-07-21T07:11:29.400 回答
2

万一您还没有解决这个问题,请确保您已正确复制并粘贴上一步 (6.3) 中的行。间距和缩进很重要,所以如果粘贴到您的文本编辑器中搞砸了,这可能是导致问题的原因。

于 2013-07-08T23:47:45.333 回答
1

做:将 .bashrc 保存为 UTF-8。

请勿:将 .bashrc 保存为 ANSI(将导致错误。)

************* ERROR LOOKS LIKE THIS ***********
Run 'git help git' to display the help index.
Run 'git help <command>' to display help for specific commands.
sh.exe": /c/Documents: No such file or directory
Usage: grep [OPTION]... PATTERN [FILE]...
Try `grep --help' for more information.
Initializing new SSH agent...
于 2015-04-17T14:40:55.077 回答