git_tutorials/Lab2/Lab2.md

24 lines
1.7 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

## 推送
在前一章我们在本地创建了版本库,现在把它推送到服务器。
### 服务器新建仓库
登录到[服务器](http://172.188.24.12:3000),点击右上角的“+”,选择“创建仓库”。
![](./git_server_create.png)
![](./git_server_create2.png)
填写“仓库名称”和“仓库描述”,正式应用时“可见性”记得勾选。
其他的默认即可,点击“创建仓库”,一个新的仓库便创建完成。
### 推送
在前一章的工作目录下右键菜单选择“TortoiseGit”,点击“推送”,弹出推送窗口。
在“目标” >> "远端"下,点击"管理"按钮,添加远程仓库的链接。
![](./git_server_push.png)
![](./git_add_push_url.png)
在URL中填写复制的链接点击确定。
选择刚添加的远程仓库“origin”点击“确定”等待推送完成。第一次推送时会做身份验证。
刷新网页,可以看到代码已经同步到服务器。
## 克隆
指将远端服务器的存储库下载到本地。如果想把别人的存储库下载到本地就用到克隆了。
拿本存储库举例在本地新建一个文件夹进入文件夹右键菜单选择“Git 克隆”,弹出克隆窗口。
![](./git_clone.png)
![](./git_server_clone_url.png)
在URL输入"http://172.188.24.12:3000/mengfanxing/git_tutorials.git"前面的链接可以在服务器存储库界面复制。点击确定开始克隆等待克隆完成然后在本地文件夹就可以看到名为“git_tutorials”的存储库。
## 拉取
多人协作工作时,常常出现服务器程序版本比本地新的情况,需要通过拉取操作维持本地和服务器的同步