Mercurial中切换分支时如何防止文件自动合并?
假设我有两个名为 default
和 newfeature
的分支。我在两个分支中都有一个名为 readme.txt
的文件。我正在开发 newfeature
分支,并对 readme.txt 进行了更改。如果我运行 hg up default
而不提交更改,Mercurial 会自动将 newfeature
中的 readme.txt 版本直接合并到 default
中。
我怎样才能改变这种行为?我担心的是开发人员在切换分支之前忘记提交,从而合并他们正在处理的任何内容。
该过程如下所示:
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>
请注意自动合并,因为我没有将更改提交到 readme.txt。 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 automatically 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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用
hg up -c
(小写“c”)。这将在更新之前检查您的工作目录。您可以在 hgrc 文件中将其设置为默认值。
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.