Github 上 Fork 项目后如何同步源项目的更新
2018-08-03 10:35
323 查看
一、问题背景
最近 Fork 了 grpc 到我的 Github 帐号grpc下,以学习之然后记录点笔记上传,但是过段时间后发现原来的项目已经有了很多代码提交,那么我该如何将这些新提交的更新同步到我的帐号下的项目里呢?通过查阅 Github 帮助文档并通过关键字
sync
fork可以找到相应的解决方案。
二、解决方案
通过前述查阅可知,要解决 Fork 项目后如何同步源项目的更新?的问题,需要如下几个步骤:1. 使用 git remote -v
命令查看远程状态
thinkerou@MacBook-Pro-thinkerou:~/opensource/grpc$ git remote -v origin https://github.com/thinkerou/grpc.git (fetch) origin https://github.com/thinkerou/grpc.git (push)
2. 使用 git remote add upstream
命令给 Fork 的项目添加上游仓库
thinkerou@MacBook-Pro-thinkerou:~/opensource/grpc$ git remote add upstream https://github.com/grpc/grpc.git[/code]3. 再次使用
git remote -v查看远程状态thinkerou@MacBook-Pro-thinkerou:~/opensource/grpc$ git remote -v origin https://github.com/thinkerou/grpc.git (fetch) origin https://github.com/thinkerou/grpc.git (push)
upstream https://github.com/grpc/grpc.git (fetch)
upstream https://github.com/grpc/grpc.git (push)4. 使用
git fetch upstream命令从上游仓库 fetch 分支到本地thinkerou@MacBook-Pro-thinkerou:~/opensource/grpc$ git fetch upstream5. 使用
git checkout master命令切换到本地主干thinkerou@MacBook-Pro-thinkerou:~/opensource/grpc$ git checkout master6. 使用
git merge upstream/master命令进行合并thinkerou@MacBook-Pro-thinkerou:~/opensource/grpc$ git merge upstream/master7. 使用
git push origin master命令提交到 Github 项目下thinkerou@MacBook-Pro-thinkerou:~/opensource/grpc$ git push origin master
至此,就完美解决了 Fork 项目后如何同步源项目的更新?的问题!三、参考资料
Configuring a remote for a fork
Syncing a fork
相关文章推荐
- 如何保持从github上fork过来的项目与作者同步更新
- github上fork别人项目后如何与源项目保持同步
- 如何在github上fork一个项目来贡献代码以及同步原作者的修改
- github上fork了别人的项目后,再同步更新别人的提交
- github上fork别人的代码之后,如何保持和原作者同步的更新
- Github上fork的项目同步更新方法
- 如何在github上fork一个项目来贡献代码以及同步原作者的修改
- github上fork了别人的项目后,再同步更新别人的提交
- gitlab或github下fork后如何同步源的新更新内容?
- github上fork别人的代码之后,如何保持和原作者同步的更新
- 如何在github上fork一个项目来贡献代码以及同步原作者的修改
- 如何在github上fork一个项目来贡献代码以及同步原作者的修改
- gitlab或者github下fork后如何同步源的新更新
- github上fork别人项目后如何与源项目保持同步
- github下fork后如何同步源库的新更新内容?
- 如何保持github上fork的项目与原项目同步
- 如何在github上fork一个项目来贡献代码以及同步原作者的修改
- github上fork项目后保持与原项目同步更新
- github下fork后如何同步源的新更新