如果分叉回购和原始回购推动了一些提交,如何更新原始回购的分叉回购? [英] How to update forked repo with original repo if both forked repo and original repo has some commits pushed?

查看:117
本文介绍了如果分叉回购和原始回购推动了一些提交,如何更新原始回购的分叉回购?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下情况:

有一个名为MASTER的回购。
forkMASTER创建FORK_MASTER。

假设在MASTER上有10个提交,并且在FORK_MASTER上有两个提交。



现在我想更新FORK。如何实现它?



我试图做同样的事情。我做了以下步骤来实现:
1)将FORK_MASTER设置为MASTER的上游。
2)git fetch upstream
3)git rebase upstream / develop
4)git push origin

但git在步骤3即git rebase上游/开发。



期待听到如何实现这一点。

解决方法

我已经使用以下命令解决了此问题:



git remote -v (检查原始回购位置)

git remote add upstream (添加上游回购路径)



git fetch上游(从上游回购仓库获取分支)



git merge upstream / --allow-unrelated-history -X our -mUpdating branch (合并从上游分支到分支分支的更改)



git push -f原点--all (将更改推送到分叉分支)



使用这些命令,我​​可以成功更新分叉分支。


I have following situation:

There is a repo with name "MASTER". Fork "MASTER" to create "FORK_MASTER".

Suppose there are 10 commits pushed on "MASTER" and there are some two commits pushed on "FORK_MASTER".

Now I want to update FORK. How to achieve it?

My attempt to do same. I did following steps for achieving this: 1) Set up upstream for "FORK_MASTER" to "MASTER". 2) git fetch upstream 3) git rebase upstream/develop 4) git push origin

But git throws conflict after step 3 i.e. git rebase upstream/develop.

Looking forward to hear on how to achieve this.

解决方案

I have solved this problem using following command:

git remote -v (To check origin repo location)

git remote add upstream (To add upstream repo path)

git fetch upstream (To fetch branch from upstream repo)

git merge upstream/ --allow-unrelated-histories -X ours -m "Updating branch" (To merge changes from upstream branch to forked branch)

git push -f origin --all (Pushing changes to forked branch)

With these commands, I am successfully abled to update forked branch.

这篇关于如果分叉回购和原始回购推动了一些提交,如何更新原始回购的分叉回购?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆