Git 问题 [Windows]:git 推送致命错误。 GitBash 和 cmd 不同步

Git Issue [Windows]: git push fatal error. GitBash and cmd not in Sync

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

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

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

这似乎和我再次 运行 时一样有效。它显示为 "fatal: remote origin already exists."

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

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.

存储库存在于 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:运行ning 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 不同步。但现在知道要检查或更改什么。

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

更新答案:

查看您更新后的问题中的详细日志记录,它成功加载 ssh 配置文件 (/c/Users/Christopher/.ssh/) 的目录与它正在寻找的目录之间似乎存在差异密钥 (/c/Users/Christopher/ssh/).

您的 ssh 配置文件似乎引用了没有“.”的目录在开始时指定密钥。

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

原答案:

错误消息 "no such identity: /c/Users/Christopher/ssh/id_rsa: No such file or directory" 告诉您它正在尝试通过 ssh 使用 public-key 身份验证,但它正在寻找的身份文件不存在。

基本上你需要创建一个 ssh 身份并在相关设置页面上将 public 密钥上传到 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