开发者

How to prevent a file from automatically merging when switching branches in Mercurial?

Let's say I have two branches named default and newfeature. I have a file called readme.txt in both branches. I'm working on the newfeature branch and I make a change to readme.txt. If I run hg up default without committing the change, Mercurial autom开发者_运维知识库atically merges the version of readme.txt in newfeature directly into default.

How can I change this behavior? What I'm worried about is developers forgetting to commit before they switch branches, thus merging whatever they've been working on.

This is what the process looks like:

C:\source\BranchTest\Main>hg branch
Exams

C:\source\BranchTest\Main>hg status
M readme.txt

C:\source\BranchTest\Main>hg up default
merging readme.txt
0 files updated, 1 files merged, 0 files removed, 0 files unresolved

C:\source\BranchTest\Main>

Notice the automatic merge because I didn't commit the change to readme.txt. Mercurial doesn't warn me that this will happen.

Any suggestions?


Use hg up -c (lower-case 'c'). This will check your working directory before updating.

You can make this the default in your hgrc file.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜