Mercurial : Updating a Fork with Changes from the Master Repository

标签 mercurial

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

场景

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

问题

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

采取的步骤

这是我尝试执行的步骤,但没有成功。

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. pull:从存储库检索更改,但不将它们应用到工作副本
  2. commit :将工作副本上的更改应用到本地目录
  3. push :将本地存储库中的所有变更集推送到远程存储库
  4. 更新(您没有使用过):将您的工作副本更新为来自本地存储库的特定变更集

您会注意到我使用了两个不同的术语:工作副本和存储库。

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

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

因此,一旦您完成拉取,如果您想将更改“应用”到您的工作副本,则必须执行更新,或者,您也可以du hg pull -u。如果您自上次拉取以来进行了一些更改,则可能必须 merge 而不是更新,如果您查看链接的文档,他们正在执行 merge (步骤3)。

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

关于push部分,您将按照错误消息所述的方式创建新分支。默认情况下,Mercurial 不会推送变更集来创建新分支,您必须使用指定的命令:hg push --new-branch 或专门推送分支hg push mybranch

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

关于 Mercurial : Updating a Fork with Changes from the Master Repository,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9662397/

相关文章:

mercurial - 如何获取当前分支的所有负责人?

svn - 当主干/分支/标签结构一团糟时,如何从 Subversion 迁移到 Mercurial?

version-control - Mercurial:有关修改文件的信息

mercurial - 生成用于访问 Mercurial 的身份验证代码

mercurial - 在 Mercurial 或 TortoiseHg 中搜索部分文件或路径的更改历史

python - 使用来自 mercurial python hook 的 Django 模型

windows - 如何在 bash/ubuntu 下通过 SSH 在 Windows 上使用 hg?

java - 我可以在 Git/Mercurial 中安全地忽略 Eclipse 项目 .metadata 的哪些内容?

deployment - Mercurial自动化部署

mercurial - 我应该在 hgignore 中放置什么以避免 mercurial 跟随子目录的内容?