Git錯誤解決(windows版本下的Git Shell)

來源:互聯網
上載者:User

標籤:help   自己   ast   user   cte   fat   rmi   agent   could   

第一個問題:怎麼也不能將自己本地倉庫代碼pull到GitHub網站上?

git push origin master

Warning: Permanently added ‘github.com,192.30.255.112‘ (RSA) to the list of known hosts.
To github.com:lanshanxiao/yunweather.git
! [rejected] master -> master (fetch first)
error: failed to push some refs to ‘[email protected]:lanshanxiao/yunweather.git‘
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., ‘git pull ...‘) before pushing again.
hint: See the ‘Note about fast-forwards‘ in ‘git push --help‘ for details.

 

 git pull origin master

Warning: Permanently added ‘github.com,192.30.255.112‘ (RSA) to the list of known hosts.
remote: Counting objects: 5, done.
remote: Compressing objects: 100% (4/4), done.
warning: no common commits
remote: Total 5 (delta 0), reused 0 (delta 0), pack-reused 0
Unpacking objects: 100% (5/5), done.
From github.com:lanshanxiao/yunweather
* branch master -> FETCH_HEAD
* [new branch] master -> origin/master
fatal: refusing to merge unrelated histories

 

 git push origin master

Warning: Permanently added ‘github.com,192.30.255.112‘ (RSA) to the list of known hosts.
To github.com:lanshanxiao/yunweather.git
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to ‘[email protected]:lanshanxiao/yunweather.git‘
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: ‘git pull ...‘) before pushing again.
hint: See the ‘Note about fast-forwards‘ in ‘git push --help‘ for details.

 

以上執行了三次,但是都報錯,雖然pull下來遠程倉庫的代碼,但是沒有 

git pull origin master//將本地倉庫代碼和遠程倉庫代碼融合

如果有下面的報錯:

fatal: refusing to merge unrelated histories//說明本地倉庫不能和遠程倉庫代碼融合

就強制允許融合:

git pull origin master --allow-unrelated-histories

 

第二個問題:儘管已經添加了SSH密碼到GitHub上,但是還是會出現Permission denied (publickey)?你可能沒有將公開金鑰添加到本機上

Warning: Permanently added ‘github.com,192.30.255.112‘ (RSA) to the list of known hosts.
Permission denied (publickey).
fatal: Could not read from remote repository.

首先,按照百度上的解決步驟,將SSH密碼(C:\Users\使用者名稱\.ssh\id_rsa.pub)中的密碼加到自己的GitHub網站上,這個可以百度。

再次運行git push origin master 還是出現上面的錯誤,接下來就是重點:

ssh-agent.exe//運行agent

ssh -vT [email protected]

ssh-add -l//小寫字母L

ssh-add

ssh-add -l//小寫字母L

上面命令是將ssh運行在本機,並將公開金鑰添加進來。

 

git ls-files//查看已經提交的檔案。

Git錯誤解決(windows版本下的Git Shell)

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.