遠端簡介

Git 中級

George Boorman

Curriculum Manager, DataCamp

本機版本庫

桌上型電腦中的本機版本庫

Git 中級

遠端版本庫

雲端中的遠端版本庫

Git 中級

為何使用遠端版本庫?

遠端版本庫的優點

  • 全部都有備份

  • 不受地點限制的協作

從屋頂看向湖面的筆電視角

Git 中級

複製版本庫(clone)

  • 我們電腦上的副本=本機遠端

  • 製作副本=cloning(複製)

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 會在新版本庫設定中儲存遠端的標籤(tag)

  • 列出與此版本庫相關的所有遠端

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...