我正在尝试使用书签而不是mercurial中的分支。原因是我不想在分支中有很多不必要的固定名称的永久物品。
当我使用单独的书签进行新功能开发并且我想将其推送到out存储库时,会出现问题。好吧,如果创建'新远程头', hg 不允许我推送。我应该怎样才能做出这样的推动,好像我正在创建一个新的分支?
Alice创建存储库:
C:\TestHg>mkdir Alice
C:\TestHg>cd Alice
C:\TestHg\Alice>hg init
C:\TestHg\Alice>echo line1>>file.txt
C:\TestHg\Alice>hg addremove
adding file.txt
C:\TestHg\Alice>hg commit -m "Initial commit."
Bob克隆了Alice的存储库:
C:\TestHg\Alice>cd ..
C:\TestHg>hg clone Alice Bob
updating to branch default
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
Alice对项目代码进行了一些更改:
C:\TestHg>cd Alice
C:\TestHg\Alice>echo line2 by Alice>>file.txt
C:\TestHg\Alice>hg commit -m "Alice continues her work on the project."
鲍勃开始使用单独的书签开始他的新酷特征工作,以确定他独立的“分支”工作:
C:\TestHg\Alice>cd ..\Bob
C:\TestHg\Bob>hg bookmarks
no bookmarks set
C:\TestHg\Bob>hg bookmark NewCoolFeature
C:\TestHg\Bob>hg bookmarks
* NewCoolFeature 0:792db6cfc262
C:\TestHg\Bob>echo line2 by Bob (as a part of New Cool Feature implementation)>>file.txt
C:\TestHg\Bob>hg commit -m "Bob starts his work on New Cool Feature"
鲍勃试图将他的更改推送到Alice的目录:
C:\TestHg\Bob>hg push -B NewCoolFeature
pushing to C:\TestHg\Alice
searching for changes
abort: push creates new remote head 38506e28a438!
(you should pull and merge or use push -f to force)
好的,首先Bob必须将Alice的更改提取到他自己的存储库中:
C:\TestHg\Bob>hg pull
pulling from C:\TestHg\Alice
searching for changes
adding changesets
adding manifests
adding file changes
added 1 changesets with 1 changes to 1 files (+1 heads)
(run 'hg heads' to see heads, 'hg merge' to merge)
好吧,现在Bob在他的存储库中有两个头,这很好。
C:\TestHg\Bob>hg glog
o changeset: 2:66beef200ba4
| tag: tip
| parent: 0:792db6cfc262
| user: Alice
| date: Sun May 20 13:10:04 2012 +0400
| summary: Alice continues her work on the project.
|
| @ changeset: 1:38506e28a438
|/ bookmark: NewCoolFeature
| user: Bob
| date: Sun May 20 13:12:26 2012 +0400
| summary: Bob starts his work on New Cool Feature
|
o changeset: 0:792db6cfc262
user: Alice
date: Sun May 20 13:08:39 2012 +0400
summary: Initial commit.
在尝试再推一次之后,Bob被要求合并。 Bob不想进行合并,因为他对New Cool Feature的工作结果还没有为合并做好准备。
C:\TestHg\Bob>hg push -B NewCoolFeature
pushing to C:\TestHg\Alice
searching for changes
abort: push creates new remote head 38506e28a438!
(did you forget to merge? use push -f to force)
Bob应该做些什么才能将他的更改推送到Alice的回购中,好像他的更改是在一个单独的分支中一样?
UPD1:在现实生活中,Alice的回购被用作开发团队所有成员的中心同步点。
答案 0 :(得分:10)
他应该:
消息就在那里,因为通常很容易在没有意识到的情况下创建一个新头。但有时候它正是你想要的,所以有覆盖开关。