将远程分支变基到 master 上,同时保持远程分支更新

Rebase remote branch onto master while keeping the remote branch updated

我正在尝试将我的远程分支变基到 master 上,但我想让远程分支指向它的提交,只是基于 master 中的不同点。

这是我的结构:

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

我愿意:

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

如果不进行某种合并,这样的变基是否可行?

在你的上下文中,你会做

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

官方参考:开头

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

之后

git rebase master
git rebase master topic

我们有

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

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

要了解有关变基的更多信息,您可以查看此 link 或在您的终端

写入 git rebase --help

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

git branch -D develop //this will remove your local develop 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

在这一步您可能会遇到一些冲突,因此请解决它们,git add FILES THAT HAD CONFLICTSgit rebase --continue

现在检查变基后是否一切正常,如果是

git push -f origin develop