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

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

问题描述

...所以我已经习惯了 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).

不过我有两个主要问题:

I have two major questions though:

  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. 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.

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

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