Skip to content

Instantly share code, notes, and snippets.

@stu43005
Last active January 3, 2016 19:09
Show Gist options
  • Save stu43005/8506439 to your computer and use it in GitHub Desktop.
Save stu43005/8506439 to your computer and use it in GitHub Desktop.

Setup

  1. 在GitHub網站上點擊repository的Fork按鈕

  2. 在電腦上Clone你建立的fork

    • git clone https://github.com/user/repo.git
    • <或>
    • 在你的fork點擊Clone in Desktop按鈕
  3. 設定remote upstream

    1. git remote add upstream https://github.com/otheruser/repo.git
    2. git fetch upstream

Sync

  1. 抓取遠端倉庫的分支及提交

    • git fetch upstream
  2. 合併遠端的變更到你的本地分支

    1. git checkout master
    2. git merge upstream/master

解決合併衝突

  1. 解决衝突

    • 直接編輯
    • <或>
    • git mergetool
  2. 重新提交

    • git commit

匯入上游的新分支

  1. 抓取遠端倉庫的分支及提交

    • git fetch upstream
  2. 建立並切換到上游分支的本地版

    • git checkout -b newbranch upstream/newbranch
  3. 當你準備好後將他推送到origin

    • git push -u origin newbranch

Reference

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment