码迷,mamicode.com
首页 > Windows程序 > 详细

Git错误解决(windows版本下的Git Shell)

时间:2017-07-26 01:40:51      阅读:856      评论:0      收藏:0      [点我收藏+]

标签: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 ‘git@github.com: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 ‘git@github.com: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 git@github.com

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

ssh-add

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

上面命令是将ssh运行在本机,并将公钥添加进来。

 

git ls-files//查看已经提交的文件。

Git错误解决(windows版本下的Git Shell)

标签:help   自己   ast   user   cte   fat   rmi   agent   could   

原文地址:http://www.cnblogs.com/lanshanxiao/p/7237110.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!