`git rebase`不更新分支吗? [英] `git rebase` not updating branch?

查看:196
本文介绍了`git rebase`不更新分支吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这个:

        master
        |   foo
        |   |
        v   v             bar
A---B---C---D             |
             \            v
              \---E---F---G

我想要这个:

        master
        |   foo
        |   |
        v   v         bar
A---B---C---D         |
         \            v
          \---E---F---G

所以认为我需要做:

git checkout bar
git rebase master

但是Git认为不是:

Current branch bar is up-to-date.

并保留一切.

我需要运行什么才能使Git做到我想要的?

What do I need to run to make Git do what I want?

推荐答案

您正在执行的git rebase版本,接受分支bar上尚未在master上的所有提交,并将其写入到master上.这是通过F提交的D,这不是您想要的,因为它不会跳过提交D.一种解决方案是使用--onto标志:

The version of git rebase that you are doing, takes all of the commits on the branch bar which are not already on master and writes them onto master. This is commits D through F, which isn't what you want because it doesn't skip commit D. One solution is to use the --onto flag:

git checkout bar
git rebase --onto master foo

此版本的rebase将在分支bar上获取所有提交,但不在分支foo上接受所有提交,并将它们重写到master上.这将精确地生成您想要的bar的历史记录.

This version of rebase will take all of the commits on the branch bar but not on branch foo and rewrite them onto master. This will result in exactly the history for bar that you want.

这篇关于`git rebase`不更新分支吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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