• GitHub


    GitHub推送代码

    [root@gitlib data]# 添加远程仓库
    GitHub地址:https://github.com/
    详细内容请参考:https://docs.github.com/cn/get-started/quickstart/hello-world

    浏览https://github.com/ 右上角 sign up注册账户在这里插入图片描述
    在这里插入图片描述
    新建仓库
    在这里插入图片描述
    在这里插入图片描述

    选择https或者ssh 上传代码 此实验选择ssh在这里插入图片描述

    进入主机

    git远程仓库操作指令

    命令功能
    git remote远程仓库操作指令
    git clone克隆代码库
    git pull下载远程仓库代码到本地
    git push上传本地代码到远程仓库

    添加远程仓库

    [root@gitlib data]#  git remote add hello-word git@github.com:Bingku1125/hello-word.git
    
    • 1

    查看远程仓库

    [root@gitlib data]# git remote
    hello-word
    
    • 1
    • 2

    配置ssh-sky免密推送代码

    [root@gitlib data]# ssh-skygen

    [root@gitlib data]# yum -y install ssh

    [root@gitlib data]# ssh-keygen
    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:AfUq4pbxmei5dAk9IRd5coIVTyB6HqBCwP/9ccA+xC8 root@gitlib
    The key's randomart image is:
    +---[RSA 2048]----+
    |+.. .o*=o        |
    |.o o..+=o.       |
    |o o + o== .      |
    |.  + = . B       |
    |    * = S o      |
    |   . O B E o     |
    |    * * . =      |
    |   + o   .       |
    |    +.           |
    +----[SHA256]-----+
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21

    [root@gitlib data]# cat /root/.ssh/id_rsa.pub #注意输入正确地址

    ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCbuvwdKC2Wa/QE+HMBdrqd6ftsBD20Ax4+R96Fgx1icB/RiA2GNCmnMGrYjEnR6cjvdrR8o/g7lr/G7zAd0nJXbKC4cG38pjqxh3ENQ9euqLmSlDcWQB3oZ8ir7kzlzQGZHdn1jnZ5oL1A7/yD43YvUsS9oCpSpdZvBH0SekCr0mH+mhgvxrLURsZw951GAXjZSEW9ggxeSDpTwwtHLQDZrsobSYuLrGPS8x72kxtib88iYlBG0DxNHlwS8N0wdCl2VcjEu3bSnWHAGvixfe/8/SpXvcnpXLTJ+1HQnA7Pmf4kuYG8FgGUxqVKTZzunVuhVzWZGJaBDAZTryeYHX root@gitlib
    
    • 1

    公钥复制粘贴在此处
    在这里插入图片描述
    小编此处已上传
    在这里插入图片描述

    上传完后
    将工作区发代码上传至暂存区、暂存区上传至从仓库 ,然后上传至github

    代码上传至github 出错

    [root@gitlib data]# git push -u hello-world master
    fatal: 'hello-world' does not appear to be a git repository
    fatal: Could not read from remote repository.
    
    Please make sure you have the correct access rights
    and the repository exists.
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6

    解决方案

    [root@gitlib data]# vim .git/config
    [
    	url = git@github.com:Xiaohuaihuai1125/hello-word.git    此处与实际路径不否git@github.com:Bingku1125/hello-word.git   更换正确路径即可
    	
    [root@gitlib data]# cat .git/config
    	url = git@github.com:Bingku1125/hello-word.git
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6

    再次推送代码成功

    [root@gitlib data]# git push -u hello-word master
    Counting objects: 39, done.
    Compressing objects: 100% (29/29), done.
    Writing objects: 100% (39/39), 3.06 KiB | 0 bytes/s, done.
    Total 39 (delta 14), reused 0 (delta 0)
    remote: Resolving deltas: 100% (14/14), done.
    To git@github.com:Bingku1125/hello-word.git
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7

    相关参考文章
    https://www.cnblogs.com/xiaostudy/p/9519003.htm
    https://blog.csdn.net/zzzzlei123123123/article/details/105174595
    https://blog.csdn.net/qq_35896136/article/details/106166079
    https://blog.csdn.net/weixin_43707560/article/details/89062133?spm=1001.2101.3001.6650.1&utm_medium=distribute.pc_relevant.none-task-blog-2%7Edefault%7ECTRLIST%7Edefault-1-89062133-blog-106166079.pc_relevant_multi_platform_featuressortv2dupreplace&depth_1-utm_source=distribute.pc_relevant.none-task-blog-2%7Edefault%7ECTRLIST%7Edefault-1-89062133-blog-106166079.pc_relevant_multi_platform_featuressortv2dupreplace&utm_relevant_index=2

    GITHUB词汇表
    https://docs.github.com/cn/get-started/quickstart/github-glossary

  • 相关阅读:
    又一短视频进军电商行业,引来众多行业人士关注!
    【爬虫笔记】Python爬虫简单运用爬取代理IP
    [100天算法】-目标和(day 79)
    Open3D 生成空间圆点云
    Pytorch框架学习记录1——Dataset类代码实战
    堆排序(数据结构)
    【树莓派4B】如何点亮树莓派的LED灯
    vue3.0 实现图片延迟加载 自定义属性
    Kotlin高仿微信-第6篇-主页-我的
    7-2 芬兰木棋 结构体排序
  • 原文地址:https://blog.csdn.net/weixin_45861372/article/details/126120687