github上fork别人的代码之后,保持和原作者同步的更新

  1. 查看git已经有的源分支
git remote -v

结果如下:

origin  https://github.com/weblazy/utils.git (fetch)
origin  https://github.com/weblazy/utils.git (push)
  1. 添加原库的源分支并命名为web
git remote add web https://github.com/weblazy/utils.git
  1. 查看git已经有的源分支
git remote -v

结果如下:

origin  https://github.com/weblazy/utils.git (fetch)
origin  https://github.com/weblazy/utils.git (push)
web     https://github.com/weblazy/utils.git (fetch)
web     https://github.com/weblazy/utils.git (push)
  1. 原库拉取远程分支
git fetch web

结果如下:

来自 https://github.com/weblazy/utils
 * [新分支]          master     -> web/master

5.查看所有分支

git branch -a

结果如下:

* master
  remotes/origin/HEAD -> origin/master
  remotes/origin/master
  remotes/web/master

6.本地master分支合并原库master分支

git merge web/master

你可能感兴趣的:(github上fork别人的代码之后,保持和原作者同步的更新)