重新根据并保留空提交 [英] Rebase on the root and keep empty commits
问题描述
假设我有一个由三个提交组成的分支,其中一个为空:
#分支测试
3208910 empty
85c949c bar
0c1a615 foo
我想重新设定它根和从手册页看来 - root --keep-empty
正是我需要的。
<但是,无论是
git rebase -i --root
和 git rebase -i --root --keep-empty
省略空的提交,然后让我看看这个计划: 选择0c1a615 foo
选择85c949c bar
如何重新绑定整个分支并同时保留空提交?
PS我需要这个来删除分支上的一些第一次提交,并且我设法通过 filter-branch
来实现,如这个SO答案,但我仍然有兴趣知道 rebase
是有能力的。我发现了Git中的错误吗?很难相信这种行为是有意的,但我不确定。
P. p。我发现我可以手动编辑计划并添加选择3208910
。
它与 git rebase
两种模式相关联。
$ b
Patch-id 方法应该保留空的提交并且是默认的行为。
然而,正如所指出的那样, - root
flag是一个到NULL的快捷方式,这会触发 fork-point 模式。 更多信息可以从
Suppose I have a branch that consists of three commits, one of them empty:
# On branch test
3208910 empty
85c949c bar
0c1a615 foo
I want to rebase it on the root and from the man page it seems that --root --keep-empty
is exactly what I need.
However, both git rebase -i --root
and git rebase -i --root --keep-empty
omit the empty commit and show me this plan instead:
pick 0c1a615 foo
pick 85c949c bar
How can I rebase the entire branch and keep empty commits at the same time?
P.S. I needed this to remove a few first commits on the branch and I managed to achieve that with filter-branch
as described in this SO answer, but I'm still interested in knowing if rebase
is capable of that. Is it a bug in Git that I found? It's hard to believe this behavior is intentional but I'm not sure.
P.P.S. I found that I can edit the plan by hand and add pick 3208910
.
It is connected with the two modes of git rebase
.
Patch-id approach should keep the empty commit and is the default behaviour.
However, as correctly pinpointed, --root
flag is a shortcut for "onto NULL" and this triggers the fork-point mode.
More information can be deducted from:
这篇关于重新根据并保留空提交的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!