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

查看远程仓库

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

配置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]-----+

[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

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

上传完后
将工作区发代码上传至暂存区、暂存区上传至从仓库 ,然后上传至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.

解决方案

[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

再次推送代码成功

[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

相关参考文章
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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值