11
#lets get the latest
git pull

#lets switch to branch and do some work
git checkout -b makeSomeBugs

#do the work commit
git add .
git commit -am "introducing some bugs"

#push this for my lazy remote friend to see
git push origin makeSomeBugs

#uh .. changes on master
git pull origin master

#do some work..
git commit -am "introducing some more bugs"
git push origin makeSomeBugs

#lets switch back to master
git checkout master
git pull

#work is done, lets merge
git merge --no-ff makeSomeBugs
git push origin

#and remove the branch to never ever see it again
git push origin :makeSomeBugs
git branch -d makeSomeBugs

各种博客资源(但它们已经很老了)说在 mercurial 中这样的分支是行不通的,尤其是在永久删除分支的情况下......

4

2 回答 2

11

我可能有一些错误,因为我可能误解了 git,但假设您使用的是最新版本的 Mercurial,或者如果不是,则启用书签扩展...

# lets get the latest
# git pull

hg pull

# lets switch to branch and do some work
# git checkout -b makeSomeBugs

hg bookmark makeSomeBugs

# do the work commit
# git add .
# git commit -am "introducing some bugs"

hg commit -m "introducing some bugs"

# push this for my lazy remote friend to see
# git push origin makeSomeBugs

hg push -B makeSomeBugs

# uh .. changes on master
# git pull origin master

hg pull
hg merge

# do some work..
# git commit -am "introducing some more bugs"
# git push origin makeSomeBugs

hg commit -m "introducing some more bugs"
hg push -B makeSomeBugs

# lets switch back to master
# git checkout master
# git pull

hg pull
hg update -C <name of master rev>

# work is done, lets merge
# git merge --no-ff makeSomeBugs
# git push origin

hg merge makeSomeBugs
hg push

# and remove the branch to never ever see it again
# (I assume you mean the label not the changesets)
# git push origin :makeSomeBugs
# git branch -d makeSomeBugs

hg bookmark -d makeSomeBugs
hg push -B makeSomeBugs

有几个“心理模型”差异,但我认为它非常接近。最大的一个是当您删除书签时。您在本地删除它,然后推送它已被删除。与你对 git 所做的相反的顺序。

还有一个问题是你用什么来识别“主”头。如果服务器上已经有一个书签(master例如称为),第一行将变为hg pull -B master, first mergehg merge master和 update hg update -C master。首次拉取书签后,任何后续拉取或推送都应更新它,而无需明确提及。

于 2012-04-25T08:08:58.347 回答
5

除了使用 Mercurial 时,您通常根本不会费心命名您的进度,而只需使用匿名分支,这几乎是相同的。

我会让它沉入一会儿...

与 git 不同,如果没有与之关联的分支名称或书签,Mercurial 不会“忘记”变更集,因此无需命名并随后删除它。在此之后,它看起来像一个非常标准的工作流程:

#lets get the latest
hg pull

#lets update to the latest and do some work
hg update

#do the work commit
hg commit -Am "introducing some bugs"

#serve this for my lazy remote friend to see
hg serve

#uh .. remote changes
hg pull

#do some work..
hg commit -Am "introducing some more bugs"

#lets pull in the latest
hg pull

#work is done, lets merge
hg merge
hg push

如果您真的想明确地跟踪匿名头部,您可以选择使用书签;当您开始(之后hg update)时,使用以下命令标记当前变更集:

hg bookmark makeSomeBugs

完成后(之后hg merge),使用以下方法删除书签:

hg bookmark -d makeSomeBugs

您也可以为您的朋友推送书签,但是……嗯。

于 2012-04-25T08:14:15.553 回答