我创建了多个分支,由于它们无处可去,所以我关闭了。这些分支之一称为v2
。它在过去的某个时间关闭。
在进一步开发时,我创建了另一个分支,也称为v2
。 Tortoise Hg警告我该分支已存在,以及我是否想“重新启动”或“提交到当前分支”。我要求重启它。
更多的开发发生在v2
(几次提交)上,我决定将其推送到已经有我的项目的远程存储库(包括先前关闭的v2
)。然后我得到消息
abort: push creates new remote head fce4441f5150 on branch 'v2'!
hint: merge or see "hg help push" for details about pushing new heads
我真的不想合并(我假设消息的意思是“将旧的
v2
与新的v2
合并”),因为这些分支没有太多共同之处。我关闭了v2
而不是将其挂起,因为我不希望再使用它了。 (关于名称重用的自我鞭打在问题的后面出现,对此无后顾之忧)这使我有了新的头脑。
hg outgoing
向我展示了我期望发生的事情...# this is the first commit for the new v2
changeset: 221:ba47b76010ef
branch: v2
user: w <w@home>
date: Fri Jul 18 14:42:08 2014 +0200
summary: New version: all frames are subclasses, frames are organiz
# some more commits for the new v2
# last commit for the new v2
changeset: 225:fce4441f5150
branch: v2
tag: tip
user: w <w@home>
date: Wed Jul 23 13:17:19 2014 +0200
summary: added manualstart.sh
...但是
v2
(旧的,已关闭)已经存在于存储库中:从现在开始我应该去哪里?
--force
参数,因为在过去它花费了我很多时间。我想确保这次可以。 总的来说,我了解到重用先前关闭的分支不是一件好事,对吗?还是可以采取一些预防措施?
最佳答案
没错,重用分支名称不是一件好事。
我看到了两种方法来满足您的需要-它们都不是真正的“好”。
1)您已经提到过-f选项。
如果您害怕推多个头,请尝试逐步插入:
hg push -r <close commit of old branch>
hg push -r <parent of 221>
hg push -f -r 221 --new-branch
hg push
2)另一个选择是从旧分支到新分支进行No-Op-Merge。
hg update -C 221
hg merge v2
hg revert -a -r 221
hg commit -m "old is marked as commited"
但是请注意,这可能会导致将来的合并出现问题,因为旧版v2中的所有更改都被标记为合并,即使它们来自分支机构或类似分支。
关于mercurial - 重新启动一个封闭的分支会产生两个头,如何插入呢?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/24909630/