zoukankan      html  css  js  c++  java
  • Linux(Centos 7)下安装Git并配置连接GitHub

    Linux(Centos 7)下安装Git并配置连接GitHub

    1、安装git Centos7 查看git --version

    2、配置用户名密码

    git config --global user.name "xxx"
    git config --global user.email "xxx@gmail.com"

    3、为GitHub账号添加SSH Keys

    ssh-keygen -t rsa -C "qiubing.it@gmail.com" 生成key
    系统会提示key的保存位置(一般是~/.ssh目录)和指定口令,保持默认,连续三次回车即可

    复制SSH Key到GITHUB
    

    打开该文件,id_rsa.pub文件内的内容,粘帖到github帐号管理的添加SSH key界面中

    cat ~/.ssh/id_rsa.pub

    登录github-> Settings-> SSH and GPG Keys-> New SSH key添加

    测试是否连接成功
    

    ssh -T git@github.com

    会提示

    The authenticity of host 'github.com (192.30.255.112)' can't be established.
    RSA key fingerprint is 16:27:ac:a5:76:28:2d:36:63:1b:56:4d:eb:df:a6:48.
    Are you sure you want to continue connecting (yes/no)? yes
    

    直接输入 yes 就可以了,然后提示成功:

    Warning: Permanently added 'github.com,192.30.255.112' (RSA) to the list of known hosts.
    Hi smartwen! You've successfully authenticated, but GitHub does not provide shell access.

    git推送到GitHub步骤:

    git init

    git add file

    git commit -m "注释"

    git remote add origin git@github.com:smartwen/selIDE

    git push -u origin master

    解决一个巨坑

    我使用了命令:

    git push -u origin master
    

    结果报错如下:

    error: failed to push some refs to 'git@github.com:你的远程库名.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,进行合并然后在进行push,
    因此先使用

    git pull --rebase origin master
    

    将远程文件同步下来。
    然后再执行推送

    git push -u origin master
    

    终于,成功!

  • 相关阅读:
    N层电梯只停一层情况下,求所有人爬楼层数最少
    小组开发用户调研
    《哈利波特》买书最优惠算法
    团队开发——极速蜗牛
    林锐——软件工程思想后两章阅读笔记
    课堂练习之检测水军
    团队开发项目-----来用------典型用户与用户场景分析
    体验结对开发的乐趣(6)--(电梯调度问题)
    团队开发项目-----来用------用户需求调研报告
    课堂练习之最高折扣,最低优惠规划
  • 原文地址:https://www.cnblogs.com/emaes/p/14000382.html
Copyright © 2011-2022 走看看