美文网首页
git 常见问题

git 常见问题

作者: Gaizka | 来源:发表于2020-08-25 17:08 被阅读0次

    问题1 : git push 问题

    git -c diff.mnemonicprefix=false -c core.quotepath=false -c credential.helper=sourcetree push -v --tags origin refs/heads/master:refs/heads/master 
    Pushing to https://user@github.com/repo.git
    To https://user@github.com/repo.git
     = [up to date]      master -> master
    ...
     ! [rejected]        example_tag -> example_tag (already exists)
    updating local tracking ref 'refs/remotes/origin/master'
    error: failed to push some refs to 'https://user@github.com/repo.git'
    hint: Updates were rejected because the tag already exists in the remote.
    Completed with errors, see above
    
    解决方案

    git pull --tags -f
    解决地址: https://github.com/concourse/git-resource/issues/233

    问题2 :

    每次都提示输入git@xxx.com 的密码 
    
    解决方案

    首先你的ssh公钥匙已经添加gitlab
    然后将私有添加在本地的ssh agent 里面,执行;ssh-add -K + 私钥
    然后依次执行:cd ~/.ssh ; ssh -T +提示输入名字的git地址进行验证 ;如果输出 Welcome to GitLab, @git名字! 说明配置成功
    验证:eg:例如项目地址 git@git.aa-zzz.com 可以执行 ssh -T git@git.aa-zzz.com , 验证如果出现: Welcome to GitLab, @git名字,说明配置成功

    扩展:增加一个ssh https://www.jianshu.com/p/31cbbbc5f9fa

    问题2

    [git]Git error: RPC failed; curl 56 LibreSSL SSL_read: SSL_ERROR_SYSCALL, errno 54

    解决方案

    原因是访问超时时长太短导致
    解决方案是增加超时时长 ,执行命令:git config --global http.postBuffer 524288000
    然后再执行:pod install --repo-update ,就可以下载对应的文件啦

    问题3

    忘记ssh私有对的密码

    解决方案
    1. 进入ssh的目录 2. ssh-keygen -f 私钥名字 -p 3. 可以重新设置密码或一路回车取消密码验证

    放弃本地没有add到stage的所有改动

    git checkout .

    问题4 撤销上一次commit,还没有push到远程仓库

    git reset --soft|--mixed|--hard <commit_id> git push develop develop --force (本地分支和远程>分支都是 develop)
    这里的<commit_id>就是每次commit的SHA-1,可以在log里查看到
    --mixed 会保留源码,只是将git commit和index 信息回退到了某个版本.
    --soft 保留源码,只回退到commit信息到某个版本.不涉及index的回退,如果还需要提交,直接>commit即可.
    --hard 源码也会回退到某个版本,commit和index 都会回退到某个版本.(注意,这种方式是改变本地代码仓库源码)

    问题5 撤销上一次commit,已push到远程仓库

    问题6: host问题导致 pod install 一直报错:

    error: RPC failed; curl 56 LibreSSL SSL_read: SSL_ERROR_SYSCALL, errno 54

    解决方式:cd 到 管理员/etc目录在hosts文件添加 13.229.188.59 github.com
    

    问题7:raw.githubusercontent.com 访问443或者超时或者太慢

    方案一:修改DNS

    修改你的电脑DNS为Google的8.8.8.8
    [图片上传失败...(image-831ac2-1621245809587)]
    点击这里查看Mac修改DNS教程

    方案二:修改代理

    此方法仅限于已经可以kexue shang wang 的同学。
    在终端中输入以下命令行(7890789 需要换成你自己的端口):

    export https_proxy=http://127.0.0.1:7890 http_proxy=http://127.0.0.1:7890 all_proxy=socks5://127.0.0.1:789
    

    再次尝试连接,应该可以了!

    方案3:删除pod/cache 下缓存即可

    rm ~/Library/Caches/CocoaPods/search_index.json
    

    问题8: 设置和取消git代理

    设置ss

    git config --global http.proxy 'socks5://127.0.0.1:1080'
    git config --global https.proxy 'socks5://127.0.0.1:1080'
    

    设置代理

    git config --global https.proxy http://127.0.0.1:1080
    git config --global https.proxy https://127.0.0.1:1080
    或者
    export all_proxy="" http_proxy="" https_proxy=""
    

    取消代理

    git config --global --unset http.proxy
    git config --global --unset https.proxy
    
    或者
    export all_proxy="" http_proxy="" https_proxy=""
    

    问题9: Failed to connect to 127.0.0.1 port 7890: Connection refused 或者 curl: (22) The requested URL returned error: 502
    原因:本地设置了不对的代理导致
    使用问题的修改方案或者按如下方式修复:

    # 方式1:通过git取消代理
    $ git config --global --unset http.proxy
    $ git config --global --unset https.proxy
    
    #方式2: export方式写入
    export all_proxy="" http_proxy="" https_proxy="" 
    
    # 方式2:通过系统命令取消代理
    $ unset http_proxy
    $ unset ftp_proxy
    $ unset all_proxy
    $ unset https_proxy
    $ unset no_proxy
    
    

    相关文章

      网友评论

          本文标题:git 常见问题

          本文链接:https://www.haomeiwen.com/subject/dtwoghtx.html