zoukankan      html  css  js  c++  java
  • Git--04 Github使用

    Github使用

    Github顾名思义是一个Git版本库的托管服务,是目前全球最大的软件仓库,拥有上百万的开发者用户,也是软件开发和寻找资源的最佳途径,Github不仅可以托管各种Git版本仓库,还拥有了更美观的Web界面,您的代码文件可以被任何人克隆,使得开发者为开源项贡献代码变得更加容易,当然也可以付费购买私有库,这样高性价比的私有库真的是帮助到了很多团队和企业

    1、注册用户

    2、配置ssh-key

    3、创建项目

    4、克隆项目到本地

    5、推送新代码到github


    #查看远程仓库
    [root@git ~/git_data]# git remote
    
    #添加远程仓库
    [root@git ~/git_data]# git remote add origin git@github.com:qiuzengjia/git_data.git
    [root@git ~/git_data]# git remote
    origin
    
    #将代码推送到远程仓库,认证失败
    [root@git ~/git_data]# git push -u origin master
    The authenticity of host 'github.com (52.74.223.119)' can't be established.
    RSA key fingerprint is
    SHA256:nThbg6kXUpJWGl7E1IGOCspRomTxdCARLviKw6E5SY8.RSA key fingerprint is MD5: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
    Warning: Permanently added 'github.com,52.74.223.119' (RSA) to the list of known hosts.
    Permission denied (publickey).
    fatal: Could not read from remote repository.
    Please make sure you have the correct access rightsand the repository exists.
    
    #生成SSH密钥对
    [root@git ~/git_data]# cd
    [root@git ~]# ssh-keygen -t rsa
    Generating public/private rsa key pair.
    Enter file in which to save the key (/root/.ssh/id_rsa):
    Enter passphrase (empty for no passphrase):
    Enter same passphrase again:
    Your identification has been saved in /root/.ssh/id_rsa.
    Your public key has been saved in /root/.ssh/id_rsa.pub.
    The key fingerprint is:
    SHA256:OTcZp1vPfXHDbMLB+3D/wW6/YSScpbC/JjMDIcqwCqo root@git
    The key's randomart image is:
    +---[RSA 2048]----+
    | |
    | . |
    | ...o . |
    | . . o == O |
    | + . S *..X O.|
    |. . o + +.oX.=|
    |o . o .o*+|
    |.. = .+.=|
    |E *..o=|
    +----[SHA256]-----+
    [root@git ~]# cat .ssh/id_rsa
    id_rsa id_rsa.pub
    [root@git ~]# cat .ssh/id_rsa.pub
    ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCkLibocGGe+jyPY2wNE50DogmPJnkjISWzSZjz8I5YBJT6bOsfA8spR/8CmGV+hmEk/ESbTbKx2yr+NeQYqoXF+8PVmKsiV51pUc+8pYYOgqzOwGKXZ6REdPFo6TeuzTwYtY2TFEoY2IolCeupKWUqA4dVOewJ/SfmAFqWcwa3fsbwH3EezO8tMNzKFz2wOYvSdYxZtEx6uKQYdcScQeJ6plAKl2kdqQ6ya/c+AR3B76pM5ItErxE5M2cVc35EcgEJLh71aXddJuepcXy76Rk0o/ISrMCcq/5wEdALYDlDEa+djO2oKaAoJcUmTEBl0n9hos3ifnCxK1d5KSINxQ5F root@git       
    

    ​ #将其复制粘贴到远程仓库中

    #重新进行推送
    [root@git ~]# cd git_data/
    [root@git ~/git_data]# git push -u origin master
    Warning: Permanently added the RSA host key for IP address 
    '13.250.177.223' to the list of known hosts.
    Counting objects: 17, done.
    Compressing objects: 100% (8/8), done.
    Writing objects: 100% (17/17), 1.25 KiB | 0 bytes/s, done.
    Total 17 (delta 1), reused 0 (delta 0)
    remote: Resolving deltas: 100% (1/1), done.
    To git@github.com:qiuzengjia/git_data.git
    * [new branch] master -> master
    Branch master set up to track remote branch master from origin.
    
    

    下图可以看到,代码已经推送成功了。

    #克隆远程仓库到本地进行测试
    [root@git ~/git_data]# cd /opt/        #将其克隆到/opt目录
    [root@git /opt]# git clone git@github.com:qiuzengjia/git_data.gitCloning into 'git_data'...
    Warning: Permanently added the RSA host key for IP address 
    '13.229.188.59' to the list of known hosts.
    remote: Enumerating objects: 17, done.
    remote: Counting objects: 100% (17/17), done.
    remote: Compressing objects: 100% (7/7), done.
    Receiving objects: 100% (17/17), done.
    Resolving deltas: 100% (1/1), done.
    remote: Total 17 (delta 1), reused 17 (delta 1), pack-reused 0
    [root@git /opt]# ll git_data/
    total 4
    -rw-r--r-- 1 root root 16 Nov 16 18:04 a
    -rw-r--r-- 1 root root 0 Nov 16 18:04 test
    
  • 相关阅读:
    34. Find First and Last Position of Element in Sorted Array
    42. Trapping Rain Water
    HDU-2952 Counting Sheep (DFS)
    HDU-1518 Square(DFS)
    HDU-1253 胜利大逃亡 (BFS)
    HDU-1026 Ignatius and the Princess I (BFS)
    最小生成树之Prim算法,Kruskal算法
    HDU-1495 非常可乐(BFS)
    strncpy 用法
    字符串函数总结
  • 原文地址:https://www.cnblogs.com/gongjingyun123--/p/11969786.html
Copyright © 2011-2022 走看看