zoukankan      html  css  js  c++  java
  • git使用之错误分析及解决(持续更新)

    错误一:

    1 使用
    2 
    3 $ git push -u origin master
    4 出现如下错误:
    5 
    6 error: src refspec master does not match any.
    7 error: failed to push some refs to 'git@github.com:hahaha/ftpmanage.git'
    View Code

    分析及处理

    1 原因:
    2 
    3 本地仓库为空
    4 
    5 解决方法:使用如下命令 添加文件;
    6 
    7 $ git add add.php addok.php conn.php del.php edit.php editok.php ftpsql.sql index.php
    8 
    9 $ git commit -m "init files"
    View Code

    错误二:

    $ git push -u origin master
    Warning: Permanently added the RSA host key for IP address 'xx.xx.xxx.xxx' to the list of known hosts.
    To git@github.com:hahaha/ftpmanage.git
     ! [rejected]        master -> master (fetch first)
    error: failed to push some refs to 'git@github.com:hahahah/ftpmanage.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.
    View Code

    分析及处理

     1 提示使用 git pull 之后在 push
     2 
     3 使用如下命令解决:
     4 
     5 复制代码
     6 $ git pull --rebase origin master
     7 warning: no common commits
     8 remote: Counting objects: 3, done.
     9 remote: Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
    10 Unpacking objects: 100% (3/3), done.
    11 From github.com:hahah/ftpmanage
    12  * branch            master     -> FETCH_HEAD
    13  * [new branch]      master     -> origin/master
    14 First, rewinding head to replay your work on top of it...
    15 Applying: init files
    View Code

     错误三:

    1 git add .时 警告warning: LF will be replaced by CRLF in
    View Code

    分析及处理

     1 原因:这是由于 ,跨平台的开发情况下产生的。
     2 
     3 详细:
     4 
     5 格式化是许多开发人员在协作时,特别是在跨平台情况下,遇到的令人头疼的细小问题。 由于编辑器的不同或者Windows程序员在跨平台项目中的文件行尾加入了回车换行符, 一些细微的空格变化会不经意地进入大家合作的工作或提交的补丁中。不用怕,Git的一些配置选项会帮助你解决这些问题。
     6 
     7 git cofig core.autocrlf
     8 
     9     1
    10 
    11 假如你正在Windows上写程序,又或者你正在和其他人合作,他们在Windows上编程,而你却在其他系统上,在这些情况下,你可能会遇到行尾 结束符问题。 这是因为Windows使用回车和换行两个字符来结束一行,而Mac和Linux只使用换行一个字符。 虽然这是小问题,但它会极大地扰乱跨平台协作。
    12 
    13 Git可以在你提交时自动地把行结束符CRLF转换成LF,而在签出代码时把LF转换成CRLF。用core.autocrlf来打开此项功能, 如果是在Windows系统上,把它设置成true,这样当签出代码时,LF会被转换成CRLF:
    14 
    15 $ git config --global core.autocrlf true
    16 
    17     1
    18 
    19 Linux或Mac系统使用LF作为行结束符,因此你不想Git在签出文件时进行自动的转换;当一个以CRLF为行结束符的文件不小心被引入时你肯定想进行修正, 把core.autocrlf设置成input来告诉Git在提交时把CRLF转换成LF,签出时不$ git config –global core.autocrlf input在Windows系统上的签出文件中保留CRLF,会在Mac和Linux系统上,包括仓库中保留LF。
    20 
    21 如果你是Windows程序员,且正在开发仅运行在Windows上的项目,可以设置false取消此功能,把回车符记录在库中:
    22 
    23 $ git config --global core.autocrlf false
    View Code

     错误四:

    1 refusing to merge unrelated histories
    View Code

    分析及处理

    1 因为他们是两个不同的项目,要把两个不同的项目合并,git需要添加一句代码,在git pull,这句代码是在git 2.9.2版本发生的,最新的版本需要添加--allow-unrelated-histories
    2 
    3 假如我们的源是origin,分支是master,那么我们 需要这样写git pull origin master ----allow-unrelated-histories需要知道,我们的源可以是本地的路径
    View Code

     错误五:

    1 提示:更新被拒绝,因为您当前分支的最新提交落后于其对应的远程分支。
    2 提示:再次推送前,先与远程变更合并(如 'git pull ...')。详见
    3 提示:'git push --help' 中的 'Note about fast-forwards' 小节。
    View Code

    分析及处理

    引起这个问题是远程仓库和本地不同步引起的
    
    解决方案:需要先获取远端更新并与本地合并,再git push
    具体操作如下: 
    git fetch origin    //获取远程更新
    git merge origin/master //把更新的内容合并到本地分支
    View Code

     错误六:

    使用$ git clone时出现server certificate verification failed. CAfile:/etc/ssl/certs/ca-certificates.crt CRLfile: none
    View Code

    分析及处理

    解决方法:在执行$ git clone 之前,在终端输入:
    
    export GIT_SSL_NO_VERIFY=1
    View Code

    错误七:

    clone时出现,unable to negotiate with 10.0.0.8: no matching key exchange methodfound. Their offer: diffie-hellman-group1-sha1
    View Code

    分析及处理

    解决方法:在执行git clone之前,在终端输入:
    
    export GIT_SSH_COMMAND='ssh -o KexAlgorithms=+diffie-hellman-group1-sha1'
    这种方法每次新开git窗口,都需要重新输入export GIT_SSH_COMMAND
    网上有说是因为客户端和服务器端git版本不一致导致的,也有说如果知道服务器ip,可以在C:UsersSpring.ssh下新建一个config文件,添加内容如下,但是好像不起作用:
    
    Host 10.0.0.8
        KexAlgorithms +diffie-hellman-group1-sha1
    还有一种方法就是,打开.bashrc文件,在终端输入:$ vim ~/.bashrc  ,然后向.bashrc文件写入:
    
    export GIT_SSH_COMMAND='ssh -o KexAlgorithms=+diffie-hellman-group1-sha1'
    保存并关闭。这样就不需要每次打开终端时都重新输入export GIT_SSH_COMMAND了。
    View Code

    错误八:

     在Windows上,使用git bash here,编译vs2013工程时,中文显示乱码
    View Code

    分析及处理

    解决方法:打开git bash here,鼠标点击右键--> Options… --> Text --> Locale 选择zh_CN,Characterset 选择GBK,点击Apply,OK即可
    View Code

    错误九:

     在Windows上写的代码移到Linux上提交时,会提示DOS line ending (CRLF) found, use Unix line ending (LF) instead
    View Code

    分析及处理

    解决方法:(1)、下载dos2unix,执行
    sudo apt-get install dos2unit
    (2)、对有问题的文件执行:
    doc2unit ../xxx.cpp
    View Code

     错误十:

    unable to negotiate with *.*.*.*: no matching key exchange methodfound. Their offer: diffie-hellman-group1-sha1
    View Code

    分析及处理

    在Windows上更新了git 版本后,clone/pull时出现错误,
    
    unable to negotiate with *.*.*.*: no matching key exchange methodfound. Their offer: diffie-hellman-group1-sha1
    
    解决方法:在执行git pull/clone之前,输入:
    
    export GIT_SSH_COMMAND='ssh -o KexAlgorithms=+diffie-hellman-group1-sha1'  
    
    这种方法每次打开git窗口,都要重新输入一次。
    
    可以在C:UsersSpring.ssh的config文件下,添加内容如下,[本人测试有作用]
    
    Host *.*.*.* 
    KexAlgorithms +diffie-hellman-group1-sha1
    View Code

     错误十一:

    error: RPC failed; curl 56 OpenSSL SSL_read: SSL_ERROR_SYSCALL, errno 10054
    fatal: the remote end hung up unexpectedly
    fatal: early EOF
    fatal: index-pack failed
    View Code

    分析及处理

    下载的项目太大
    方法1:
    
    改成ssh推送
    
    方法2:
    
    把推送的缓存扩大
    #首先设置通信缓存大小
    git config http.postBuffer 524288000  
    #然后把缓存清除
    git filter-branch --index-filter 'git rm -r --cached --ignore-unmatch <file/dir>' HEAD
    View Code
  • 相关阅读:
    C# ListView应用
    C# 使用System.Speech 进行语音播报和识别
    支付宝支付-扫码支付详解
    使用git提交项目到码云
    C# byte[]数组和string的互相转化 (四种方法)
    C#中字节数组byte[]、图片image、流stream,字符串string、内存流MemoryStream、文件file,之间的转换
    C# 结构体和List<T>类型数据转Json数据保存和读取
    对 JSON 数据进行序列化和反序列化
    win10与虚拟机fedora14使用samba文件共享
    serialVersionUID, ObjectInputStream与ObjectOutputStream类,Serializable接口,serialVersionUID的作用和用法
  • 原文地址:https://www.cnblogs.com/navysummer/p/8907511.html
Copyright © 2011-2022 走看看