Git配置远程仓库(密匙链接)
Git配置远程仓库(密匙链接)
主机名 | IP | 备注 |
---|---|---|
git01 | 192.168.200.31 | git测试客户端一 |
git02 | 192.168.200.32 | git测试客户端二 |
1.建立远程仓库
首先在浏览器中输入网址https://github.com
#服务器创建密匙
[root@git01 ~]# ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
Created directory '/root/.ssh'.
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:hqeoMxJx57FYYqSsryd3KD6DpAXCMgLXFM8G/LqfACY root@git01
The key's randomart image is:
+---[RSA 2048]----+
| ++. |
|. o o+ |
|++ .+ |
|Oo+ +... |
|E*o* +. S |
|o+o.+. + |
|++ .o.. |
|*oB.o. . |
|oO++ .o |
+----[SHA256]-----+#查看密匙
[root@git01 ~]# cat /root/.ssh/id_rsa.pub
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCfJK+sdi8thBg+0VpbuBYyJIm5u4Mzrrk9jmu36/m9gEJiIsVkzWR4F51uuNwYwqEWuCl4f7BY/rDGe/eRlv4c2Qn0C0APNjNqRNXQXEfm7HFnWrjc75TybX3OkM6CEskKwAqB7YTNwFSt0DTic8sOuQKp+Y1o32n9tr/gjUCPZkx3+NLbXODws/Lroew0p21XVNH4Fd8H/k6/uciLm5vpXmBhy5a49uikkn0Jyx/wRUNZfRAhkmRKBTVgzdrcZ8W0yQjyFP7DjiCwnBXzP9NKyAhOVXlpEnfpGfqUBFZPl8c/SzHPDNbedbdM9CTbly0cm0yDgrO+TUjD6b7a87E7 root@git01
2.yum安装git客户端
[root@git01 ~]# yum -y install git[root@git01 ~]# git --version
git version 1.8.3.1
3.init初始化GIT工作目录
[root@git01 ~]# mkdir -p /mycode
[root@git01 ~]# cd /mycode/
[root@git01 mycode]# git init
初始化空的 Git 版本库于 /mycode/.git/
4.add将变更添加进入暂存区
[root@git01 mycode]# touch test.txt
[root@git01 mycode]# echo "这是一次测试" > test.txt
[root@git01 mycode]# cat test.txt
这是一次测试[root@git01 mycode]# git add test.txt
[root@git01 mycode]# git status #查看git工作目录的暂存区状态
# 位于分支 master
#
# 初始提交
#
# 要提交的变更:
# (使用 "git rm --cached <file>..." 撤出暂存区)
#
# 新文件: test.txt
#
5.Git全局配置
[root@git01 mycode]# git config --global user.name "Mr.yang"
[root@git01 mycode]# git config --global user.email "1773464408@qq.com"#说明:如果没有提前设置Git的全局配置,那么在第一次进行代码提交的时候,会要求输入使用者的邮箱和姓名
6.commit将变更从暂存区提交到本地仓库
[root@git01 mycode]# git commit -m "第一次测试"
[master(根提交) 84a5a58] 第一次测试1 file changed, 1 insertion(+)create mode 100644 test.txt
7.remote add添加一个远程仓库的URL
[root@git01 mycode]# git remote add test git@github.com:ywb971108/ceshi.git[root@git01 mycode]# git remote -v
test git@github.com:ywb971108/ceshi.git (fetch)
test git@github.com:ywb971108/ceshi.git (push)
8.push将本地仓库的变更推送到远程仓库的某个分支
命令格式: git push -u <远程仓库的名字> <远程仓库的某一分支名字>
[root@git01 mycode]# git push -u test master
The authenticity of host 'github.com (13.250.177.223)' 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,13.250.177.223' (RSA) to the list of known hosts.
Counting objects: 3, done.
Writing objects: 100% (3/3), 246 bytes | 0 bytes/s, done.
Total 3 (delta 0), reused 0 (delta 0)
To git@github.com:ywb971108/ceshi.git* [new branch] master -> master
分支 master 设置为跟踪来自 test 的远程分支 master。
9.刷新浏览器查看
10.clone克隆一个现有仓库到本地
我们在另一台git02上来模拟其他客户端进行对远程仓库克隆到本地仓库的操作
git02服务器需要添加密匙到github
[root@git02 ~]# mkdir -p /mycode2
[root@git02 ~]# cd /mycode2/[root@git02 mycode2]# git clone git@github.com:ywb971108/ceshi.git
正克隆到 'ceshi'...
Warning: Permanently added the RSA host key for IP address '52.74.223.119' to the list of known hosts.
remote: Enumerating objects: 3, done.
remote: Counting objects: 100% (3/3), done.
remote: Total 3 (delta 0), reused 3 (delta 0), pack-reused 0
接收对象中: 100% (3/3), done.
[root@git02 mycode2]# ls
ceshi[root@git02 mycode2]# cd ceshi/
[root@git02 ceshi]# ls
test.txt[root@git02 ceshi]# cat test.txt
这是一次测试
11.修改仓库里的文件内容,并提交变更到本地,推送变更到远程仓库
[root@git02 ceshi]# echo "客户端测试" >> test.txt
[root@git02 ceshi]# cat test.txt
这是一次测试
客户端测试[root@git02 ceshi]# git add test.txt
[root@git02 ceshi]# git commit -m "增加了一行内容"
[master 1c90ca0] 增加了一行内容1 file changed, 1 insertion(+)
12.客户端推送到远程仓库
#添加对远程仓库的管理
[root@git02 ceshi]# git remote add test git@github.com:ywb971108/ceshi.git#推送到远程仓库
[root@git02 ceshi]# git push test master
Counting objects: 5, done.
Writing objects: 100% (3/3), 299 bytes | 0 bytes/s, done.
Total 3 (delta 0), reused 0 (delta 0)
To git@github.com:ywb971108/ceshi.git84a5a58..1c90ca0 master -> master
13.web页面查看推送结果
Git配置远程仓库(密匙链接)相关推荐
- git配置远程仓库,同时配置github、gitee、gitlab,完美解决方案
git同时配置github.gitee.gitlab 清除 git 的全局设置(针对已安装 git) 生成新的 SSH keys 1)GitHub 的钥匙 2)GitLab 的钥匙 3)Gitee 的 ...
- Git连接远程仓库(私有/公开仓库),克隆代码
Git连接远程仓库(私有/公开仓库),克隆代码 1.下载安装Git: git官网下载地址: https://git-scm.com/download/win 但是 ,git官网的话,下载速度比较慢,可 ...
- 【Git】使用Git连接远程仓库GitHub
[Git]使用Git连接远程仓库GitHub 1. 添加远程仓库 1.1 在github上创建仓库 1.2 SSH协议 1.3 同步到远程仓库 1.3.1 使用git bash 1.3.2 使用Tor ...
- git连接远程仓库以及常用命令
git连接远程仓库以及常用命令 git 连接远程仓库 git ssh key配置 本地配置 git配置 git连接远程仓库 关联远程仓库(将本地仓库推送到新的远程仓库) git常用命令(包括clone ...
- Git本地远程仓库的搭建(局域网内也可提交)
寂书万卷 2018-07-09 16:02:06 13357 收藏 23 展开 Git本地远程仓库的搭建(windows 7专业版) 你是否也这样想过?可以在自己的两台或者多台电脑中创建一个仓 ...
- git修改远程仓库关联
公司搬移, 作为git仓库的服务器IP地址变了. 本地代码挺多,重新检出太占时间,可以修改一个什么配置让我本地仓库和新的远程仓库建立关联吗, 答案是肯定的! 方法有很多,这里简单介绍几种: 以下均以项 ...
- 使用git 添加远程仓库 或者 从远程仓库克隆的两种实现
使用git 添加远程仓库 1-先配置本地git git init git config --global user.eamil "1500070188@qq.com" 邮件地址 g ...
- 解决git添加远程仓库提示出错信息:fatal: remote origin already exists
解决git添加远程仓库提示出错信息:fatal: remote origin already exists. 解决办法如下:1.先输入$ git remote rm origin2.再输入$ git ...
- 【Ubuntu安装git与git clone远程仓库】
在远程ubuntu安装git 连接远程服务器 可以通过pycharm,vscode,SecureCRT等工具配置连接远程服务器 pycharm远程连接服务器完整教程 Windows下如何使用VScod ...
最新文章
- 参数处理:#{}与${}取值的区别
- 如何避免贫穷和忙碌,在2018年你需要这样提升自己 2018年01月07日 00:00:00 2099 热文导读 | 点击标题阅读 Java和Android架构2017年总结:文章精选 吊炸天!74
- osgi框架和spring区别_最全153道Spring全家桶面试题,你都知道哪些?(含答案解析)...
- 聊一聊Elasticsearch和MySQL的常用操作
- 导师要让你学会的“显规则”
- Struts 2中文件上传
- HTML5_2(视频)
- 易用宝项目记录day5-shiro
- Language Models are unsupervised multitask learners
- 股票量化分析(11)——第二个策略(5日移动均线、双均线、MACD策略)
- 文件头格式标准魔数-magic number和mime.types
- python的基础数据类型
- [世界概览]那些被印度人毁掉或者差一点毁掉的公司(翻译)
- 怎样让android系统消失,谷歌本以为断供安卓可以让华为手机消失,结果断送了安卓系统的前程...
- 设备树常用奇奇怪怪速查
- 获取屏幕、当前网页和浏览器窗口的大小
- GEE:两种遥感影像的中值合成方法
- CAN通信(一)——认识CAN总线
- 大数据周会-本周学习内容总结013
- 亿图图示:批量转化Visio的操作方法