zoukankan      html  css  js  c++  java
  • Git错误解决(windows版本下的Git Shell)

    第一个问题:怎么也不能将自己本地仓库代码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用户名.sshid_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//查看已经提交的文件。

  • 相关阅读:
    Android Loader异步装载
    Android 清除本地缓存
    Android 小知识
    Android 百度地图用法
    ANDROID笔记:四大组件之广播
    Android扩展:一个自动findViewById的小工具
    ANDROID笔记:基于handle的异步请求网络数据的一种方法
    ANDROID笔记:多线程断点下载
    ANDROID笔记:AIDL介绍
    ANDROID笔记:activity通过ContentProvider传值(仿调用系统图片浏览器过程)
  • 原文地址:https://www.cnblogs.com/lanshanxiao/p/7237110.html
Copyright © 2011-2022 走看看