网站查询工具,为网站 做字幕,城市建设法规考试网站,网站自助服务建设策划本站以分享各种运维经验和运维所需要的技能为主 《python零基础入门》#xff1a;python零基础入门学习 《python运维脚本》#xff1a; python运维脚本实践 《shell》#xff1a;shell学习 《terraform》持续更新中#xff1a;terraform_Aws学习零基础入门到最佳实战 《k8… 本站以分享各种运维经验和运维所需要的技能为主 《python零基础入门》python零基础入门学习 《python运维脚本》 python运维脚本实践 《shell》shell学习 《terraform》持续更新中terraform_Aws学习零基础入门到最佳实战 《k8》从问题中去学习k8s 《docker学习》暂未更新 《ceph学习》ceph日常问题解决分享 《日志收集》ELK各种中间件 《运维日常》运维日常 《linux》运维面试100问 《DBA》db的介绍使用mysql、redis、mongodb... 1.什么是github
Github顾名思义是一个Git版本库的托管服务是目前全球最大的软件仓库拥有上百万的开发者用户也是软件开发和寻找资源的最佳途径
Github不仅可以托管各种Git版本仓库还拥有了更美观的Web界面您的代码文件可以被任何人克隆使得开发者为开源项贡献代码变得更加容易
当然也可以付费购买私有库这样高性价比的私有库真的是帮助到了很多团队和企业
详细操作参考https://zhuanlan.zhihu.com/p/37078615
1、注册用户
2、配置ssh-key
3、创建项目
4、克隆项目到本地
5、推送新代码到github
2.github使用
1注册用户
#1.访问网站 https://github.com/
#2.右上角 sign up
#3.填写注册信息
#4.右上角点击 sign in 登录
2创建远程仓库 页面跳转可根据提示进行操作 3添加远程仓库
[rootgit git_data]# git remote add origin gitgithub.com:tcy110/gt_data.git
4查看远程仓库
[rootgit git_data]# git remote
origin
5推送代码到远程仓库
#创建一个文件到工作区域
[rootgit git_data]# touch test_gihub#将数据添加到暂存区
[rootgit git_data]# git add test_gihub#提交到本地仓库
[rootgit git_data]# git commit -m 提交到本地仓库
[master efa9480] 提交到本地仓库1 file changed, 0 insertions(), 0 deletions(-)create mode 100644 test_gihub#提交到远程仓库
[rootgit git_data]# git push -u origin master
The authenticity of host github.com (13.250.177.223) cant 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,13.250.177.223 (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 rights
and the repository exists.
#认证失败因为我们通过ssh进行推送的需要输入ssh连接密码我们不知道密码所以被拒绝
6做免密把我们的服务器与github做免密登录
1.生成密钥对
[rootgit git_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:/URpF1/tB0ZaZTaTfnwlKZs32PqV9Dh4P15F5Rqrcfw rootgit
The keys randomart image is:
---[RSA 2048]----
| .O|
| .BB|
| B|
| . ooB*|
| S . o*oB|
| ooo|
| oo E|
| ..o|
| ...|
----[SHA256]-----2.获取公钥
[rootgit git_data]# cat /root/.ssh/id_rsa.pub
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDUjihOjWKimah6x/1d0oTc4tro0Yq18lZBHnI/elLVZwo/ZnQFP37RIYPuqNcTptaEJzjNgwyvUGf6uiQ6sxGCQ1LL3XkHUEVMYMa/OM4h/wI4/EQOf6D6aAoZJ2RqH4PHKuxidyWKl7viqYItgWki3yEeUBhNRPY1FOQxGJhg6FviwpoABtXHybEY0yjjZ/FsWDzuZLnabj46YawrSyUmTD6iSqbdvOeFtbv9v8NcaYSar2Rgl9HPOvb1ezx/sfwGra1pqL1Rly6AqDdGGazaumNAyPr04GWuFTxx1imcjRmhFqsz2LcwCKLjLw3z2skNrtlPb2Cw/ET3iqXsr rootgit3.将公钥加到平台的ssh公钥中 7再次测试提交
[rootgit git_data]# git push -u origin master
Warning: Permanently added the RSA host key for IP address 13.229.188.59 to the list of known hosts.
Counting objects: 31, done.
Compressing objects: 100% (19/19), done.
Writing objects: 100% (31/31), 2.69 KiB | 0 bytes/s, done.
Total 31 (delta 2), reused 0 (delta 0)
remote: Resolving deltas: 100% (2/2), done.
To gitgithub.com:a893874/git_data.git* [new branch] master - master
Branch master set up to track remote branch master from origin.
8到页面查看 3.代码拉取与推送
1克隆仓库到本地
[rootgit tmp]# git clone gitgithub.com:a893874/git_data.git
Cloning into git_data...
Warning: Permanently added the RSA host key for IP address 52.74.223.119 to the list of known hosts.
remote: Enumerating objects: 31, done.
remote: Counting objects: 100% (31/31), done.
remote: Compressing objects: 100% (17/17), done.
remote: Total 31 (delta 2), reused 31 (delta 2), pack-reused 0
Receiving objects: 100% (31/31), done.
Resolving deltas: 100% (2/2), done.[rootgit tmp]# ll
total 0
drwxr-xr-x 3 root root 59 Sep 22 00:32 git_data# 注意
git clone https://github.com/oldboylzy/git_test.git
低版本的系统存在版本问题提示
fatal: unable to access https://github.com/oldboylzy/oldboy.git/: Peer reports incompatible or unsupported protocol version
yum update -y nss curl libcurl #升级版本即可
[rootgit git_test]# touch d
[rootgit git_test]# git add .
[rootgit git_test]# git commit -m add d
[rootgit git_test]# git push -u origin master
[rootgit git_data]# cd /root/git_data/
[rootgit git_data]# git pull # 拉取远程仓库最新代码、然后进行上传 2拉取代码
[rootgit opt]# mkdir git_data
[rootgit opt]# cd git_data/#先初始化
[rootgit git_data]# git init
Initialized empty Git repository in /opt/git_data/.git/
#再拉取代码
[rootgit git_data]# git pull gitgithub.com:a893874/git_data.git
remote: Enumerating objects: 31, done.
remote: Counting objects: 100% (31/31), done.
remote: Compressing objects: 100% (17/17), done.
remote: Total 31 (delta 2), reused 31 (delta 2), pack-reused 0
Unpacking objects: 100% (31/31), done.
From github.com:a893874/git_data* branch HEAD - FETCH_HEAD
#查看
[rootgit git_data]# ll
total 8
-rw-r--r-- 1 root root 4 Sep 22 00:35 3
-rw-r--r-- 1 root root 12 Sep 22 00:35 master
-rw-r--r-- 1 root root 0 Sep 22 00:35 test_gihub
3推送代码
[rootgit git_data]# echo 12354667890 1.txt
[rootgit git_data]# git add 1.txt
[rootgit git_data]# git commit -m 测试拉取代码修改后提交到远程仓库
[master e0a401f] 测试拉取代码修改后提交到远程仓库1 file changed, 1 insertion()create mode 100644 1.txt#查看远程仓库暂时还没有
[rootgit git_data]# git remote
#添加远程仓库
[rootgit git_data]# git remote add origin gitgithub.com:a893874/git_data.git
[rootgit git_data]# git remote
origin#推送数据
[rootgit git_data]# git push -u origin master
Counting objects: 4, done.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 392 bytes | 0 bytes/s, done.
Total 3 (delta 0), reused 0 (delta 0)
To gitgithub.com:a893874/git_data.gitefa9480..e0a401f master - master
Branch master set up to track remote branch master from origin.
4页面查看推送的代码 5同步原来的代码目录
#回到最初的代码目录没有刚提交的新代码需要重新拉取
[rootgit git_data]# git pull gitgithub.com:a893874/git_data.git
remote: Enumerating objects: 4, done.
remote: Counting objects: 100% (4/4), done.
remote: Compressing objects: 100% (2/2), done.
Unpacking objects: 100% (3/3), done.
remote: Total 3 (delta 0), reused 3 (delta 0), pack-reused 0
From github.com:a893874/git_data* branch HEAD - FETCH_HEAD
Auto-merging master
Merge made by the recursive strategy.1.txt | 1 master | 1 test_gihub | 03 files changed, 2 insertions()create mode 100644 1.txtcreate mode 100644 test_gihub[rootgit git_data]# ll
total 12
-rw-r--r-- 1 root root 12 Sep 22 00:41 1.txt
-rw-r--r-- 1 root root 4 Sep 17 17:40 3
-rw-r--r-- 1 root root 16 Sep 22 00:41 master
-rw-r--r-- 1 root root 0 Sep 22 00:41 test_gihub