Github fork 仓库与原仓库同步

  • 进入 fork 项目目录,查看你的远程仓库路径
git remote -v
origin  https://github.com/YOUR_UERNAME/YOUR_FORK.git (fetch)
origin  https://github.com/YOUR_UERNAME/YOUR_FORK.git (push)
  • 配置原仓库路径
git remote add upstream https://github.com/ORIGINAL_OWNER/ORIGINAL_REPOSITORY.git
  • 再次查看远程目录位置
git remote -v
origin  https://github.com/YOUR_UERNAME/YOUR_FORK.git (fetch)
origin  https://github.com/YOUR_UERNAME/YOUR_FORK.git (push)
upstream https://github.com/ORIGINAL_OWNER/ORIGINAL_REPOSITORY.git (fetch)
upstream https://github.com/ORIGINAL_OWNER/ORIGINAL_REPOSITORY.git (push)
  • 抓取原仓库的修改文件
git fetch upstream
  • 切换到 master 分支
git checkout master
  • 合并远程的 master 分支
git merge upstream/master

推荐阅读更多精彩内容