• Git远程连接GitHub


    1.创建 ssh key;

     $ssh-keygen -t rsa -C "youremail@example.com"  youremail@example.com为设置的邮箱

      不用设置密码 一直回车;  id-rsa 是私钥;id-rsa.pub 是公钥;

    2. 登录GitHub; 打开Account settings;

      然后,点“Add SSH Key”,填上任意Title,在Key文本框里粘贴id_rsa.pub文件的内容:

    3.  添加远程-本地版本库 关联;

      $git remote add origin  git@github.com:zccxy/Repository.git  

      

    4.把本地库推送到远程;

      $git push -u origin master   origin默认远程库;

      由于远程库是空的,我们第一次推送master分支时,加上了-u参数,Git不但会把本地的master分支内容推送的远程新的master分支,还会把本地的master分支和远程的    master分支关联起来,在以后的推送或者拉取时就可以简化命令

      以后就可以用$git push origin master 提交远程;

      遇到的问题:

      error: failed to push some refs to 'git@github.com:zccxy/Repository.git'

      解决方法:

      $git pull origin master

      在上传之前先pull;  

       遇到的问题:

        error: src refspec master does not match any

      解决方法:

      引起该错误的原因是,目录中没有文件,空目录是不能提交上去的

      touch README

      git add README

      git commit -m 'first commit'

       git push origin master

    遇到问题

      $ git push -u origin master
      To https://github.com/zccxy/repo-2-5
       ! [rejected]        master -> master (non-fast-forward)
      error: failed to push some refs to 'https://github.com/zccxy/repo-2-5'
      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.


    解决方法:

      $git push - u origin master -f  强制提交;

      


     5.从远程 克隆

      $get clone git@github.com:zccxy/Repository.git

       遇到问题; SSL certificate problem: unable to get local issuer certificate
      这里其实是电脑没有安装对应的ca证书,所以无法通过https连接到git服务器。

      git config --global http.sslVerify false

      之后再进行 git clone即可。

      

    [Power By XIAOWU]
  • 相关阅读:
    Oracle中有大量的sniped会话
    Error 1130: Host '127.0.0.1' is not allowed to connect to this MySQL server
    汉字转换为拼音以及缩写(javascript)
    高效率随机删除数据(不重复)
    vs2010 舒服背景 优雅字体 配置
    mvc中的ViewData用到webfrom中去
    jquery ajax return值 没有返回 的解决方法
    zShowBox (图片放大展示jquery版 兼容性好)
    动感效果的TAB选项卡 jquery 插件
    loading 加载提示······
  • 原文地址:https://www.cnblogs.com/webmans/p/8088107.html
Copyright © 2020-2023  润新知