git 在保持远程分支更新的同时将远程分支重新设置为 master

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/39920992/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 12:19:50  来源:igfitidea点击:

Rebase remote branch onto master while keeping the remote branch updated

gitrebasegit-remote

提问by Andrew

I am trying to rebase my remote branch onto master, but I want to keep the remote branch pointing to it's commits, just based at a different point in master.

我试图将我的远程分支重新绑定到 master,但我想让远程分支指向它的提交,只是基于 master 中的不同点。

Here is my structure:

这是我的结构:

A - B - C - D  (origin/master)
 \
  R - S - T (origin/develop)

I would like:

我想:

A  - B - C - D (origin/master) - R - S - T (origin/develop)

Is such a rebase possible without some sort of merge?

如果没有某种合并,这样的变基是否可能?

回答by Lucas Batista Gabriel

to see more about rebase you can check this linkor write git rebase --helpat your terminal

要查看有关 rebase 的更多信息,您可以查看此链接git rebase --help在您的终端上写信

To solve your problem there is a easy way, follow this steps:

要解决您的问题,有一个简单的方法,请按照以下步骤操作:

git branch -D develop //this will remove your local develp repository
git fetch //update references 
git checkout develop //change to develop branch, but because you deleted, this command will also download the origin/develop
git rebase -p origin/master

at this step you can have some conflits, so resolve then and git add FILES THAT HAD CONFLITSand git rebase --continue

在这一步你可能会遇到一些冲突,所以解决然后git add FILES THAT HAD CONFLITSgit rebase --continue

Now check if everything steel working after rebase, if yes

现在检查重新定位后所有钢材是否正常工作,如果是

git push -f origin develop

git push -f origin develop

回答by Do Nhu Vy

In your context, you will do

在你的上下文中,你会做

git rebase origin/master    
git rebase origin/master origin/develop

Official reference: At the beginning

官方参考:一开始

      A---B---C topic
     /
D---E---F---G master

after do

做完之后

git rebase master
git rebase master topic

we have

我们有

              A'--B'--C' topic
             /
D---E---F---G master

(Source: https://git-scm.com/docs/git-rebase)

(来源:https: //git-scm.com/docs/git-rebase