如何合并Mercurial中的更改
我使用hg clone在本地文件夹中获取项目的工作副本如何合并Mercurial中的更改,mercurial,Mercurial,我使用hg clone在本地文件夹中获取项目的工作副本 hg clone http://example.com/prj 我想修改一些文件以满足我的需要。例如,原始文件如下所示: int main() { cout << "hello"; return 0; } 我的变化inta=0丢失。有关分布式SCM如何工作以及如何使用它们的速成课程,请阅读 或: 实际上,如果您在进行更改后记得hg commit,则不会发生这种情况。 您将只拥有一个具有两个头的存储库
hg clone http://example.com/prj
我想修改一些文件以满足我的需要。例如,原始文件如下所示:
int main() {
cout << "hello";
return 0;
}
我的变化
inta=0代码>丢失。有关分布式SCM如何工作以及如何使用它们的速成课程,请阅读
或:
实际上,如果您在进行更改后记得hg commit
,则不会发生这种情况。
您将只拥有一个具有两个头的存储库,您需要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;
} | } | }
$hg pull
从/tmp/remote拉出
搜索更改
添加变更集
添加舱单
添加文件更改
添加了1个更改集,其中1个更改为1个文件(+1个头)
(运行“hg头”查看头,“hg合并”合并)
$hg合并
int main(){| int main(){| int main(){
int a=0;| for(int i=0;i您的意思是我必须在“hg pull”之前运行“hg commit”?在您进行更改后,是的。对不起……您的意思是我必须运行1)hg commit,2)hg pull,3)hg merge,4)hg update?是的。或者更具体地说1.hg clone
2.进行更改3.hg commit
4.hg pull
5.hg merge
6.hg commit
(用于合并)7.(可选)hg push
您永远不必在拉取之前提交。在更新之前提交可能是个好主意,但是如果不提交,您不应该丢失更改;更新应该将您的工作副本更改合并到新版本中。在您的特定示例中,似乎存在冲突,因此需要在更新后解决冲突呃更新了,但是仍然没有丢失您的更改。
int main() {
for (int i=0; i<10; i++ )
cout << "hello";
return 0;
}
hg pull
hg update
$ 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;
} | } | }