Git:从上游转入开发分支 [英] Git: rebase onto development branch from upstream

查看:119
本文介绍了Git:从上游转入开发分支的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有本地的 master develop 分支。我将所有工作都放在 develop 上,然后将它们合并到版本的 master 中。有一个远程分支 upstream / master ,它有我想要的更改,但我想重新设置 develop中的更改 (它共享一个共同的祖先),并将它们放回到 develop 中。我已经完成 git fetch upstream



Git书籍关于重定义的章节说要做的事:

  $ git checkout experiment 
$ git rebase master

其中我假设)在我的情况下将意味着:

$ $ p $ $ code $ git checkout upstream / master
$ git rebase develop

但是我会在 upsteam / master 和在分离头部状态。但是,如果我做了 upstream / master 的合并,我会从 develop 这样做,在$ 开发,例如$ git merge upstream / master

所以这种重新分配方式似乎落后于我。我想在开发分支中改变开发中的更改,其中上游/主类似于合并的工作方式。我应该在 upstream / master 上进行rebase,修正所有冲突,然后添加它,将其保存并将其弹出到 develop

希望这是有道理的,有人可以帮助我,这将是感激。

解决方案

rebase实际上是:

  git checkout develop 
git rebase upstream / master

git rebase 应阅读:重新分配我目前的分支,这里开发目标分支之上,这里 upstream / master



最终的结果不会是分离的头部,但是新重写的开发分支。


I have local master and develop branches. I do all my work on develop and then merge them into master for releases. There is a remote branch, upstream/master which has changes I want, but I want to rebase my changes in develop (which shares a common ancester) on top of its changes and put them back into develop. I've already done git fetch upstream.

The Git book chapter on rebasing says to do:

$ git checkout experiment
$ git rebase master

Which I (assume) in my case would mean:

$ git checkout upstream/master
$ git rebase develop

But then I'd be on the upsteam/master and in detached head state. However, if I did a merge of upstream/master, I'd do that from develop, and the changes would be on develop, e.g.

$ git checkout develop
$ git merge upstream/master

So this way to rebase seems backward to me. I'd like to rebase my changes in develop on the develop branch with the changes from upstream/master similar to how the merge would work. Am I supposed to do the rebase on upstream/master, fix any conflicts, and then add it, stash it and pop it onto develop?

Hopefully this makes sense and someone can help me with this, it would be gratefully appreciated.

解决方案

The rebase would actually be:

git checkout develop
git rebase upstream/master

(git rebase should read: "rebase my current branch, here develop, on top of target branch, here upstream/master")

And the end result wouldn't be a detached head, but the newly rewritten develop branch.

这篇关于Git:从上游转入开发分支的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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