`git rebase`不更新分支吗? [英] `git rebase` not updating branch?
问题描述
我有这个:
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屋!