远程简介

Git 中级

George Boorman

Curriculum Manager, DataCamp

本地仓库

桌面电脑中的本地仓库

Git 中级

远程仓库

云端的远程仓库

Git 中级

为何使用远程仓库?

远程仓库的优势

  • 一切都有备份

  • 跨地域协作

从屋顶和湖面望去的笔记本视角

Git 中级

克隆仓库

  • 本机上的仓库副本 = 本地远程

  • 创建副本 = 克隆

git clone path-to-project-repo
  • 克隆本地项目
git clone /home/george/repo
  • 克隆并命名本地项目
git clone /home/george/repo new_repo
Git 中级

克隆远程仓库

  • 远程仓库通常托管在在线服务

    • 如 GitHub、Bitbucket、GitLab
  • 如果我们有账号:

    • 可将远程仓库克隆到本机
git clone URL
git clone https://github.com/datacamp/project
Git 中级

识别远程

  • 克隆仓库时

    • Git 会记住源位置
  • Git 在新仓库配置中存储远程的名称标签

  • 列出与该仓库关联的所有远程

git remote
datacamp
Git 中级

获取更多信息

  • 获取远程的更多信息
git remote -v
datacamp     https://github.com/datacamp/project (fetch)
datacamp     https://github.com/datacamp/project (pull)
Git 中级

创建远程

  • 克隆时,Git 会自动将远程命名为 origin
git remote add name URL
  • 创建名为 george 的远程
git remote add george https://github.com/george_datacamp/repo
  • 命名远程便于合并
Git 中级

让我们练习!

Git 中级

Preparing Video For Download...