Skip to content

Instantly share code, notes, and snippets.

@xlui
Created March 24, 2018 11:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xlui/2578bf3ac686dfbd807d000efd36bbf3 to your computer and use it in GitHub Desktop.
Save xlui/2578bf3ac686dfbd807d000efd36bbf3 to your computer and use it in GitHub Desktop.
GitHub Fork 之后同步上游代码

GitHub Fork 了项目之后,如果上游有更新,我们可能需要手动同步更新下来。

首先,克隆 Fork 的项目:

git clone git@github.com:FORK_USERNAME/FORK_REPO.git --depth=1
cd FORKREPO

然后,添加原有项目地址为 upstream:

git remote add upstream https://github.com/ORIGIN_USERNAME/ORIGIN_REPO.git

拉取上游更新:

git fetch upstream

合并进本地:

git checkout master
git merge upstream/master

然后推送至 GitHub 即可:

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