git - 更新fork的master&重新分配我的分支到它? [英] git - update fork's master & rebase my branch onto it?

查看:178
本文介绍了git - 更新fork的master&重新分配我的分支到它?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



然后我在 my_github / the_project repo。



然后我添加并提交了更改并推送到我的github仓库并提交了一个请求。



房主已收到我的请求,并希望我重新贴上主人以获取最新更改。我怎么做到这一点?



最初我以为我可以只用 git fetch rebase在我当前的分支(因为大多数帖子我发现建议...),但 git fetch 没有做任何事情。现在我已经意识到这可能是因为我仍然从 my_ github / repo clone(这是我的名字放在遥控器中),它还没有得到我认为我可能需要做的是刷新我的叉,以便我的叉的主人是最新的,然后然后我可以获取该主人然后然后 rebase到那个主人?



<如果是这种情况,我该怎么做我的福克斯高手的刷新?如果不是这样?



我应该为原始上游存储库添加一个远程服务器,并使用该远程服务器(本地)重新绑定?这是首选的方法吗?

解决方案

是的,由于您推测的原因,它没有提取任何东西。是的,你应该在本地为上游添加一个远程设备;它会在master上快速合并。

  git checkout master#确保你在master 
git远程添加作者original_repo_that_you_forked_from
#注意:格式为git@github.com:authors_name / repo_name.git
#只需要定义一次,然后取回然后使用它。
git fetch author
git status#确保你在master分支中进行以下合并
git merge author / master#ie'into'master branch
git checkout your -branch
git rebase master#现在将这些修改放到你的分支中。
git push origin your_branch#你也可以使用`-f`和`--all`

(抱歉,我可能没有完全正确的语法)


I have forked a github project, then cloned it locally.

I then made some changes in a new branch on my_github/the_project repo.

I then added and committed the changes and pushed to my github repo and submitted a pull request.

The owner has received my request and would like me to "rebase onto master" to get the latest changes. How do I do this?

Initially I thought I could just git fetch and rebase master from within my current branch (as most posts I found advise...), but git fetch didn't do anything. Now I've realized that it is presumably because I'm still fetching from my_ github/repo clone (it's my name in the remotes after all) which hasn't yet got the new changes in master from the github source owner.

I think what I probably need to do is "refresh" my fork so that my fork's master is up-to-date and then I can fetch that master and then rebase on to that master?

If this is the case how can I do that refresh of my forks master? If not how else?

Should I add a remote for the original upstream repository and use that to rebase with (locally)? Is this the preferred method?

解决方案

Yes, it's not fetching anything because of the reason you surmised. And yes, you should add a remote for upstream locally; it will do a fast-forward merge on master.

git checkout master # Make sure you are in master
git remote add author original_repo_that_you_forked_from
    # Note: This is in the format git@github.com:authors_name/repo_name.git
    #       Only needs definition once, future fetches then use it. 
git fetch author
git status # make sure you are in the master branch for the following merge
git merge author/master  # i.e. 'into' your master branch
git checkout your-branch
git rebase master        # Now get those changes into your branch.
git push origin your_branch # You can also use `-f` if necessary and `--all`

(sorry, I might not have the syntax exactly right)

这篇关于git - 更新fork的master&amp;重新分配我的分支到它?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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