簡體   English   中英

Git問題[Windows]:git push致命錯誤。 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用戶名...

好像在我再次運行此命令時一樣。 它顯示為“致命:遠程源已存在”。

運行推送的控制台輸出如下:

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:運行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 /用戶/ Christopher / 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:// <用戶名> @ bitbucket.org / <用戶名/>hello-app.git

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM