Mercurial:使用主存储库中的更改更新Fork

时间:2012-03-12 06:02:25

标签: mercurial

我正在关注这篇文章Codeplex: Updating a Fork with Changes from the Master Repository,但它似乎对我不起作用。由于我是Mercurial的新手,我可能会遗漏一些东西......

方案

这是主存储库和我的fork的URL。几个月前我从主存储库创建了一个fork。

问题

我无法使用主存储库中的更改来更新我的fork。

采取的步骤

这是我尝试做的步骤,但它没有用。

PS C:\michael sync\git\nuget> hg clone https://hg.codeplex.com/forks/michaelsync/msyncwillmakeyoubetter
destination directory: msyncwillmakeyoubetter
requesting all changes
adding changesets
adding manifests
adding file changes
added 2231 changesets with 13584 changes to 3800 files
updating to branch default
1205 files updated, 0 files merged, 0 files removed, 0 files unresolved

PS C:\michael sync\git\nuget> cd .\msyncwillmakeyoubetter

PS C:\michael sync\git\nuget\msyncwillmakeyoubetter> hg pull https://hg.codeplex.com/nuget
pulling from https://hg.codeplex.com/nuget
searching for changes
adding changesets
adding manifests
adding file changes
added 301 changesets with 2574 changes to 838 files (+1 heads)
(run 'hg heads' to see heads)

PS C:\michael sync\git\nuget\msyncwillmakeyoubetter> hg commit -m "sync the changes from main respo to my fork"
nothing changed

PS C:\michael sync\git\nuget\msyncwillmakeyoubetter> hg push
pushing to https://hg.codeplex.com/forks/michaelsync/msyncwillmakeyoubetter
searching for changes
abort: push creates new remote branches: 1.6, 1.6.1, 1.7!
(use 'hg push --new-branch' to create new remote branches)

我不明白的是,从主存储库中提取代码之后怎么没有变化。它说我尝试提交时没有任何改变。

我查看了这些帖子How can I get the changes from a "master" repository in mercurial for a project hosted on google code?Mercurial - how to fetch latest changes from parent of fork?,但直到现在才开始工作。

1 个答案:

答案 0 :(得分:7)

首先,了解您使用的各种命令究竟是什么非常重要:

  1. pull:从存储库中检索更改,但不将它们应用于工作副本
  2. commit:将工作副本上的更改应用到本地目录
  3. push:将本地存储库中的所有更改集推送到远程存储库
  4. update(您没有使用):将您的工作副本更新为来自本地存储库的特定变更集
  5. 你会注意到我使用了两个不同的术语,工作副本和存储库。

    存储库是所有可用的变更集,包括各种分支,头等。

    工作副本是您在文件资源管理器中实际看到的文件,它们可以与存储库中的最后一个变更集完全不同。

    因此,一旦您执行了pull,如果您要将更改“应用”到工作副本,则必须执行update,或者您也可以hg pull -u 。如果您自上次pull后做了一些更改,则可能需要merge而不是更新,如果您查看已关联的文档,则会执行merge(步骤3)。

    如果update成功,则无需执行commit,更改已在您的本地存储库中。如果您必须执行merge,则需要commit来确认您所做的更改。

    关于push部分,您正在创建新分支,如错误消息所述。默认情况下,Mercurial不会推动更改集创建新分支,您必须使用所声明的命令:hg push --new-branch或专门推送分支hg push mybranch

    我希望我的解释足够清楚,否则请随意发表评论。我还建议您阅读一些关于Mercurial的教程,例如:http://hginit.com/

相关问题