Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/mercurial/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Git和Mercurial:在Mercurial中,Git工作流的等价物是什么?_Git_Mercurial - Fatal编程技术网

Git和Mercurial:在Mercurial中,Git工作流的等价物是什么?

Git和Mercurial:在Mercurial中,Git工作流的等价物是什么?,git,mercurial,Git,Mercurial,各种博客来源(但都很老)说,在mercurial中这样的分支是行不通的,尤其是永久性的分支删除…我可能有一些错误,因为我可能误解了git,但是假设您使用的是mercurial的最新版本,或者如果没有,则启用了 #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

各种博客来源(但都很老)说,在mercurial中这样的分支是行不通的,尤其是永久性的分支删除…

我可能有一些错误,因为我可能误解了git,但是假设您使用的是mercurial的最新版本,或者如果没有,则启用了

#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
#让我们了解最新信息
#吉特拉力
汞拉力
#让我们切换到分支并做一些工作
#git checkout-b makesomebug
hg书签使一些错误
#这项工作有承诺吗
#git添加。
#git commit-am“引入了一些bug”
hg commit-m“引入一些bug”
#把这个推给我的懒惰的远方的朋友看
#git推送源代码makeSomeBugs
hg-push-B制造一些bug
#嗯。。母版的更改
#git拉源主机
汞拉力
汞合并
#做些工作。。
#git提交-我“引入了更多的bug”
#git推送源代码makeSomeBugs
hg commit-m“引入更多bug”
hg-push-B制造一些bug
#让我们切换回master
#git签出主机
#吉特拉力
汞拉力
hg更新-C
#工作完成了,让我们合并吧
#git合并--没有ff makeSomeBugs
#git推送原点
hg合并一些错误
汞推力
#把树枝移开,再也见不到它了
#(我想您指的是标签,而不是变更集)
#git推送源代码:makeSomeBugs
#git分支-d makesomebug
hg bookmark-d makeSomeBugs
hg-push-B制造一些bug
有两个“心理模型”的不同,但我认为这非常接近。最大的问题是当你删除书签时。您在本地删除它,然后推送它已删除。与您对git所做的操作相反


还有一个问题是,你用什么来识别“大师”头像。如果服务器上已经有书签(例如称为
master
),第一行将成为
hg pull-B master
,第一个merge
hg merge master
和update
hg update-C master
。一旦你第一次拉入书签,任何后续的拉入或推入操作都应该在不需要明确提及的情况下对其进行更新。

这几乎是一样的,只是对于Mercurial,你通常根本不需要命名进度,只需使用匿名分支即可

我会让这件事慢慢过去

与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
如果你真的想明确地跟踪匿名头部,你可以选择使用书签;开始时(在
hg update
之后),使用以下内容标记当前变更集:

#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 merge
之后),使用以下方法删除书签:

hg bookmark makeSomeBugs

你也可以为了朋友的缘故推书签,但是。。。meh.

我已经尝试过,但还没有找到在mercurial中模拟git分支工作流的方法。常规分支不自信地无法工作,因为您无法删除它们(仅关闭它们,但这意味着分支名称将被永久使用)。书签应该像git分支一样,但至少对我来说,它们似乎并不像git分支那样工作。@ryanzec书签怎么会让你失望呢?你在默认提交,我在提交分支。这是不一样的。因为我可以从master创建另一个分支,并执行与第一个分支无关的任何其他操作。不,您正在提交一个新的匿名分支,可以选择使用书签。每当提交行发散时,就会发生分支。如果要在
默认值
名称之外的其他名称下提交,则需要创建另一个命名分支。您在这里遇到了一个文化障碍:使用匿名分支在Mercurial中很常见,而在Git中几乎不可能。命名分支是永久性的,需要提前设置;如果要跟踪匿名分支,可以使用书签。在Mercurial中,命名分支是永久性的,通常用于跟踪发布。您也可以使用它们跟踪功能,但功能工作通常在匿名分支中完成。书签可以选择性地用于跟踪匿名分支上的工作。如果您同时处理多个事项,或者在将代码合并回之前需要共享代码,这将非常有用。命名分支很适合跟踪发布,因为这样您就可以在项目历史记录中看到发布更改集的用途。但是,对于功能工作,它们通常是不方便的,例如,因为您不想费心想出一个分支名称,或者您在意识到要给它们添加标签之前已经提交了一些内容,或者(如您的问题中所述)您不希望标签持续存在。这就是为什么功能通常在匿名分支上完成,并根据需要撒上一些书签(或单独的克隆)的原因。如果您没有使用任何书签,并且已经发布了BugX的提交,那么如何开始处理BugY,但将提交从BugX中排除?我认为这只有在我使用书签的情况下才有可能(考虑到我不使用命名分支的永久性),所以问题是,在历史上可以看到,当makeSomeBugs合并为默认值并推送到原点时,在makeSomeBugs中所做的更改仍然作为makeSomeBugs中的更改可见吗?例如,我可以跟踪comit X和commit Y是在合并后在makeSomeBugs中生成的吗?@gerasalus:不,就像Git分支一样,书签不是永久的。命名分支是永久性的标签,它们没有Git等价物<代码>默认值指默认的命名分支。它与
master
@PaulS不同:现在不需要再启用书签扩展,因为它现在已经成为Mercurial的核心功能。
hg bookmark -d makeSomeBugs