0

我是 git 新手。我正在尝试将我的新项目推送到我的 bitbucket 存储库,但它似乎不起作用。我已经正确添加了我的 ssh 密钥并运行:

git remote add origin git@bitbucket.org:<username>/hello-app.git

用户名已被我的 bitbucket 用户名替换...

当我再次运行它时,这似乎已经奏效了。它显示“致命:远程来源已经存在”。

运行推送的控制台输出如下:

C:\rails-dev\hello-app>git push -u origin --all
no such identity: /c/Users/Christopher/ssh/id_rsa: No such file or directory
Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

该 repo 存在于 bitbucket 上,并且运行本地命令没有问题。只是 git push 命令。我在这个网站上看到了很多问题,并尝试了无济于事的解决方案。

目前我的 git 是通过 RailsInstaller 安装的。上面的命令在正常的 cmd 提示符下运行,而不是 GitBash shell。

编辑:“git remote -v”的输出

C:\rails-dev\hello-app>git remote -v
origin  git@bitbucket.org:c_parry/hello-app.git (fetch)
origin  git@bitbucket.org:c_parry/hello-app.git (push)

编辑 2:运行 ssh -v -T git@bitbucket.org 的输出(在 GitBash shell 中)

logged in as c_parry.

You can use git or hg to connect to Bitbucket. Shell access is disabled.

输出在项目目录中运行相同的命令。

C:\rails-dev\hello-app>ssh -v -T git@bitbucket.org
OpenSSH_6.6.1, OpenSSL 1.0.1i 6 Aug 2014
debug1: Reading configuration data /c/Users/Christopher/.ssh/config
debug1: /c/Users/Christopher/.ssh/config line 1: Applying options for     bitbucket.org
debug1: Connecting to bitbucket.org [104.192.143.2] port 22.
debug1: Connection established.
debug1: identity file /c/Users/Christopher/ssh/id_rsa type -1
debug1: identity file /c/Users/Christopher/ssh/id_rsa-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_6.6.1
debug1: Remote protocol version 2.0, remote software version OpenSSH_5.3
debug1: match: OpenSSH_5.3 pat OpenSSH_5* compat 0x0c000000
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-ctr hmac-md5 none
debug1: kex: client->server aes128-ctr hmac-md5 none
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<3072<8192) sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY
debug1: Server host key: RSA 97:8c:1b:f2:6f:14:6b:5c:3b:ec:aa:46:46:74:7c:40
debug1: Host 'bitbucket.org' is known and matches the RSA host key.
debug1: Found key in /c/Users/Christopher/.ssh/known_hosts:1
debug1: ssh_rsa_verify: signature correct
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: Roaming not allowed by server
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Trying private key: /c/Users/Christopher/ssh/id_rsa
no such identity: /c/Users/Christopher/ssh/id_rsa: No such file or directory
debug1: No more authentication methods to try.
Permission denied (publickey).

我在想我的 gitbash 和我的 cmd 不同步。但是现在知道要检查或更改什么。

4

2 回答 2

1

要将数据推送到 bitbucket 存储库,您需要在 bitbucket 中拥有用户帐户以及存储库的写入权限。请核实。

于 2016-02-09T12:54:29.417 回答
1

更新答案:

查看更新问题中的详细日志记录,它成功加载 ssh 配置文件的目录 (/c/Users/Christopher/.ssh/) 和它正在寻找密钥的目录 (/ c/用户/克里斯托弗/ssh/)。

看起来您的 ssh 配置文件指的是没有“。”的目录 在它指定密钥的开头。

(我在下面留下了原始答案,以防其他人搜索类似的错误消息)

原答案:

错误消息“没有这样的身份:/c/Users/Christopher/ssh/id_rsa:没有这样的文件或目录”告诉您它正在尝试通过 ssh 使用公钥身份验证,并且它正在寻找的身份文件没有'不存在。

基本上你需要在相关设置页面上创建一个 ssh 身份并将公钥上传到 Bitbucket,那么你应该很高兴。

这个页面有一个分步教程:https ://confluence.atlassian.com/bitbucket/set-up-ssh-for-git-728138079.html

如果您不想完成所有这些操作,则可以通过在“git remote add”行中指定相关的 https URL 来通过 https 进行连接。URL 可能类似于:https://<username>@bitbucket.org/<username/>hello-app.git

于 2016-02-09T13:00:25.010 回答