博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
git fork库同步代码_如何将您的Fork与原始Git存储库同步
阅读量:2521 次
发布时间:2019-05-11

本文共 3819 字,大约阅读时间需要 12 分钟。

git fork库同步代码

You're contributing to an open-source project, and you noticed that your fork is out of sync with the original repository. How can you correct that?

您正在为一个开源项目做贡献,并且注意到您的fork与原始存储库不同步。 您该如何纠正?

TL; DR版本 (TL;DR version)

# Add a new remote upstream repositorygit remote add upstream https://github.com/ORIGINAL_OWNER/ORIGINAL_REPOSITORY.git# Sync your forkgit fetch upstreamgit checkout mastergit merge upstream/master

添加新的远程上游存储库 (Add a new remote upstream repository)

You cloned your fork on your laptop and started to work on your issue.

您在笔记本电脑上克隆了叉子,并开始解决您的问题。

Did you know that your fork is an orphan? If you list the configured remote repository you will only see your fork as origin:

你知道你的叉子是孤儿吗? 如果列出已配置的远程存储库,则只会看到派生作为源:

git remote -vorigin  https://github.com/YOUR_USERNAME/YOUR_FORK.git (fetch)origin  https://github.com/YOUR_USERNAME/YOUR_FORK.git (push)

There are no signs of parents! Where is the original repository?

没有父母的迹象! 原始存储库在哪里?

We need to configure this information to restore the family relationship by adding a new remote upstream repository:

我们需要配置此信息以通过添加新的远程上游存储库来恢复家族关系:

git remote add upstream https://github.com/ORIGINAL_OWNER/ORIGINAL_REPOSITORY.git

You saved the family! You can now see both the original repository and the fork:

你救了家人! 现在,您可以同时看到原始存储库和分支:

git remote -vorigin    https://github.com/YOUR_USERNAME/YOUR_FORK.git (fetch)origin    https://github.com/YOUR_USERNAME/YOUR_FORK.git (push)upstream  https://github.com/ORIGINAL_OWNER/ORIGINAL_REPOSITORY.git (fetch)upstream  https://github.com/ORIGINAL_OWNER/ORIGINAL_REPOSITORY.git (push)

同步你的叉子 (Sync your fork)

Everything is now set up. You can sync your fork with only 2 commands.

现在一切都已设置。 您只能使用2个命令来同步fork。

Be sure you're in the root of your project and also in the master branch. Otherwise, you can check out to the master branch:

确保您既在项目的根目录中,又在master分支中。 否则,您可以签出到master分支:

git checkout masterSwitched to branch 'master'

Now, you have to fetch the changes from the original repository:

现在,您必须从原始存储库中获取更改:

git fetch upstreamremote: Enumerating objects: 16, done.remote: Counting objects: 100% (16/16), done.remote: Compressing objects: 100% (7/7), done.remote: Total 7 (delta 5), reused 0 (delta 0), pack-reused 0Unpacking objects: 100% (7/7), 1.72 Kio | 160.00 Kio/s, done.From https://github.com/ORIGINAL_OWNER/ORIGINAL_REPOSITORY   909ef5a..0b228a8  master     -> upstream/master

And merge the changes in your master branch:

并在您的master分支中合并更改:

git merge upstream/masterUpdating 909ef5a..0b228a8Fast-forward node.js/WorkingWithItems/batch-get.js               | 51 ++++++++++++++++++++++++++------------------------ node.js/WorkingWithItems/batch-write.js             | 95 +++++++++++++++++++++++++++++++++++++++++++++++---------------------------------------------- node.js/WorkingWithItems/delete-item.js             | 37 ++++++++++++++++++------------------ node.js/WorkingWithItems/get-item.js                | 31 +++++++++++++++++-------------- node.js/WorkingWithItems/put-item-conditional.js    | 51 +++++++++++++++++++++++++------------------------- node.js/WorkingWithItems/put-item.js                | 49 ++++++++++++++++++++++++------------------------ node.js/WorkingWithItems/transact-get.js            | 51 ++++++++++++++++++++++++++------------------------ node.js/WorkingWithItems/transact-write.js          | 79 ++++++++++++++++++++++++++++++++++++++++------------------------------------- node.js/WorkingWithItems/update-item-conditional.js | 51 ++++++++++++++++++++++++++------------------------ node.js/WorkingWithItems/update-item.js             | 47 ++++++++++++++++++++++++---------------------- 10 files changed, 282 insertions(+), 260 deletions(-)

That's it! Your fork is now up to date.

而已! 您的叉子现在是最新的。

Any questions? Feel free to contact me on !

任何问题? 随时通过与我联系!

翻译自:

git fork库同步代码

转载地址:http://bmgwd.baihongyu.com/

你可能感兴趣的文章
编译HBase1.0.0-cdh5.4.2版本
查看>>
结构体指针
查看>>
迭代器
查看>>
Food HDU - 4292 (结点容量 拆点) Dinic
查看>>
Ubuntu安装Sun JDK及如何设置默认java JDK
查看>>
[经典算法] 排列组合-N元素集合的M元素子集
查看>>
Codeforces 279D The Minimum Number of Variables 状压dp
查看>>
打分排序系统漫谈2 - 点赞量?点赞率?! 置信区间!
查看>>
valgrind检测linux程序内存泄露
查看>>
Hadoop以及组件介绍
查看>>
1020 Tree Traversals (25)(25 point(s))
查看>>
第一次作业
查看>>
“==”运算符与equals()
查看>>
单工、半双工和全双工的定义
查看>>
Hdu【线段树】基础题.cpp
查看>>
时钟系统
查看>>
BiTree
查看>>
5个基于HTML5的加载动画推荐
查看>>
水平权限漏洞的修复方案
查看>>
静态链接与动态链接的区别
查看>>