远程库
添加远程库
1.1 gitlab上创建项
1.2 本地仓库关联远程仓库,本地仓库的内容推送到GitLab仓库,远程库的名字就是origin
,这是Git默认的叫法,也可以改成别的:
$ git remote add origin clone with SSH(
clone with SSH可在下图找到
)
![](https://img2020.cnblogs.com/blog/1040133/202012/1040133-20201202114218403-799189988.png)
1.3 先把本地上传内容到git上
1.4 推送成功后,可以立刻在GitLab页面中看到远程库的内容已经和本地一样
![](https://img2020.cnblogs.com/blog/1040133/202012/1040133-20201202114843807-723551346.png)
1.5 把本地master
分支的最新修改推送至GitLab,只需执行此命令,你就拥有了真正的分布式版本库!
$ git push origin master
克隆远程库(Git支持多种协议,包括https
,但ssh
协议速度最快。若多个人协作开发,每个人各自从远程克隆一份就可以了)
2.1 创建远程库gitskills(参考图一,勾选Initialize this repository with a README
,GitLab会自动为我们创建一个README.md
文件)
![](https://img2020.cnblogs.com/blog/1040133/202012/1040133-20201202155309590-1834606467.png)
2.2 用命令git clone 克隆本地库
$ git clone clone with SSH(
clone with SSH参考图二
)
2.3 gitskills
目录查看
$ cd gitskills
$ ls
README.md