git - 将远程分支 rebase 到 master 上,同时保持远程分支更新

标签 git rebase git-remote

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

这是我的结构:

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

我愿意:

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

如果不进行某种 merge ,这样的 rebase 是否可行?

最佳答案

要了解有关 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

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

git push -f origin develop

关于git - 将远程分支 rebase 到 master 上,同时保持远程分支更新,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39920992/

相关文章:

git - nix-prefetch-git sha256 要求对标签使用修订版

git - 使用 Git Bash 显示当前目录中的文件?

git - 为什么 .git/refs/remotes 中的 git remote sill 的旧名称?

git - 如何成功 checkout 同事的存储库?

github - 错误: Undo last git commit on both local and remote

git - 对文件所做的任何更改,git 都会在 .history/中创建未跟踪的文件

java - MVN 没有创建带有阴影的 Fat Jar

具有 merge 子项的 Git rebase 分支

自动生成文件的 Git rebase 失败

Git 交互式 rebase 挤压提交 - 任何快捷方式