如何合并 Mercurial 中的更改

发布于 2025-01-07 17:47:45 字数 573 浏览 0 评论 0原文

我已使用 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;丢失了。

I have used hg clone to get a working copy of a project on a local folder

hg clone http://example.com/prj

I want to modify some files to meet my needs. For example an original file looks like:

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

So I change that like this:

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

Later the main repository changes and looks like this (compare to the first snippet):

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

Now when I run

hg pull
hg update

my change int a=0; is lost.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

宛菡 2025-01-14 17:47:45

有关分布式 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,请阅读 在线图书

For a crash course of how distributed SCM's work, and moreover HOW to use them please read either

Or:

Actually, this does not happen, if you remember to hg commit after you make the change.
You will just have a repository with 2 heads, that you would need to hg merge e.g:

$ 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;
  }                       |  }                       |  }

To learn how to use mercurial, please read the online book

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文