如何合并Mercurial中的更改

时间:2012-02-21 07:34:00

标签: mercurial

我已经使用hg clone来获取本地文件夹上项目的工作副本

hg clone http://example.com/prj

我想修改一些文件以满足我的需求。例如,原始文件如下所示:

int main() {
   cout << "hello";
   return 0;
}

所以我改变了这样:

int main() {
   int a = 0;
   cout << "hello";
   return 0;
}

稍后主存储库会发生变化,看起来像这样(与第一个代码段相比):

int main() {
   for (int i=0; i<10; i++ )
      cout << "hello";
   return 0;
}

现在我跑

hg pull
hg update

我的更改int a=0;已丢失。

1 个答案:

答案 0 :(得分:3)

有关分布式SCM如何工作的速成课程,以及如何使用,请阅读

或者:

实际上,如果您在进行更改后记得hg commit,则会发生。 您将拥有一个包含2个头的存储库,您需要hg merge例如:

$ hg pull
pulling from /tmp/remote
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)
$ hg merge
  int main() {            |  int main() {            |  int main() {
      int a = 0;          |      for (int i=0; i<10 ;|      cout << "hello";    
      cout << "hello";    |          cout << "hello";|  ------------------------
      return 0;           |      return 0;           |      return 0;
  }                       |  }                       |  }

要了解如何使用mercurial,请阅读online book