最佳实践:分支与克隆,以及部分合并? [英] best practices in mercurial: branch vs. clone, and partial merges?

查看:83
本文介绍了最佳实践:分支与克隆,以及部分合并?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

...所以我已经习惯于使用Mercurial(addcommitdiff)的简单内容,并且发现了.hgignore文件(是的!),并开始创建并在分支(branchupdate -C)之间切换.

...so I've gotten used to the simple stuff with Mercurial (add, commit, diff) and found out about the .hgignore file (yay!) and have gotten the hang of creating and switching between branches (branch, update -C).

我有两个主要问题:

  1. 如果我在分支"Branch1"中,并且想从分支"Branch2"中提取部分但不是全部更改,我该怎么做?特别是如果所有更改都在一个子目录中. (我想我可以克隆整个存储库,然后使用Beyond Compare之类的目录合并工具来选择我的编辑.似乎应该有一种方法可以将更改仅隔离到一个文件或一个目录中. )

  1. If I'm in branch "Branch1" and I want to pull in some but not all of the changes from branch "Branch2", how would I do that? Particularly if all the changes are in one subdirectory. (I guess I could just clone the whole repository, then use a directory-merge tool like Beyond Compare to pick&choose my edits. Seems like there ought to be a way to just isolate the changes in one file or one directory, though.)

使用update -C在分支之间切换似乎很容易,我想知道为什么还要麻烦使用clone.我只能想到几个原因(请参阅下文)-我是否还缺少其他一些原因?

Switching between branches with update -C seems so easy, I'm wondering why I would bother using clone. I can only think of a few reasons (see below) -- are there some other reasons I'm missing?

a.如果我需要一次处理两个版本/分支(例如执行性能指标差异)

a. if I need to act on two versions/branches at once (e.g. do a performance-metric diff)

b.进行备份(将存储库clone存储到物理位置不同的网络驱动器中)

b. for a backup (clone the repository to a network drive in a physically different location)

c.像我上面提到的那样进行选择合并.

c. to do the pick&choose merge like I've mentioned above.

推荐答案

我将克隆用于:

  • 寿命短的本地分支机构
  • 克隆到不同的开发机器和服务器

以前的用法对我来说很少见-主要是在我尝试一个我可能想完全放弃的想法时.如果要合并,则要合并所有更改.这种分支主要用于跟踪不同开发人员的分支,以使它们不会互相干扰.只是为了澄清最后一点:

The former use is pretty rare for me - mainly when I'm trying an idea I might want to totally abandon. If I want to merge, I'll want to merge ALL the changes. This sort of branching is mainly for tracking different developers' branches so they don't disturb each other. Just to clarify this last point:

  • 我继续进行我的更改,并拉出我的同工开发人员的变更,然后他们拉下了我的.
  • 在我方便的时候,我会将这些分支中一个(或全部)的所有更改合并到我的分支中.

对于功能分支或寿命更长的分支,我使用命名分支,它们在存储库之间更方便地共享而不合并.当您要有选择地合并时,它也感觉"更好.

For feature branches, or longer lived branches, I use named branches which are more comfortably shared between repositories without merging. It also "feels" better when you want to selectively merge.

我基本上是这样看的:

  • 命名分支用于开发应用程序的不同分支或版本
  • 克隆用于管理对同一应用程序版本的不同贡献.

这是我的看法,尽管这实际上是政策问题.

That's my take, though really it's a matter of policy.

这篇关于最佳实践:分支与克隆,以及部分合并?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆