zoukankan      html  css  js  c++  java
  • 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]
  • 相关阅读:
    成为一名优秀程序员所需要知道的那些事
    程序员致富的若干方法探讨
    解决Flex程序在chrome,safari,IE9等浏览器中history的后退与前进问题
    flex4里的状态(state)
    Flex和Flash定时器 setTimeout & setInterval 使用要点
    Flex十种武器(Flex Power Tools: Explorers)
    给你的组件加一个处理事件的属性
    程序员:增加编程经验的另外3种途径
    Flex常用功能代码
    常用Flex IOC框架比较分析
  • 原文地址:https://www.cnblogs.com/webmans/p/8088107.html
Copyright © 2011-2022 走看看