hg 的 merge 和 update 的区别
来源:互联网 发布:js中选中radio 编辑:程序博客网 时间:2024/05/21 17:15
1.理解一
The need to merge vs. update isn't about whether or not the changes conflict, it's about whether you have a split in your commit history. If you have a history like this:
[A]--[B]--[C]--UNCOMMITTEDCHANGESHERE
and you pull down --[D] your uncomitted changes will be combined with D when you update.
If, however you have committed so that you have:
[A]--[B]--[C]--[E]
and you pull you'll have:
[A]--[B]--[C]--[E] \ -[D]
and you'll need to merge to get down to a single head.
For the record, that's a better idea. Updating with uncommitted changes is a non-reversible action, which is always a little scary. If you've committed, you can always undo/redo a merge until you're happy with the combination.
P.S. Someone is probably going to suggest the fetch
extension, and they're dead wrong.
If you have local commits: merge. If you have uncommitted local modifications: update (which will merge).
Usually when you make a commit locally, it forks the tree when you pull. In this case you always have to merge (or rebase with the rebase extension). If you have uncommitted local modifications, then when you pull, you can update and merge the changes into your workspace.
hg book:http://hgbook.red-bean.com/
2.理解二
hg update
is about making your working directory the same than a given revision- hg merge won't reset your working directory to a given revision (it still refers the same), but will merge changes from another revision into your current working directory.
So after a pull, an hg update will change your working directory to reflect what you have pulled into your repository.
But hg merge will not reset your working directory, only merge the changes between your working directory and what you have pulled.
hg pull -u
will pull and update, refusing to merge or overwrite local changes.
- If the pull add a new HEAD in your repo, you will need to merge
added 1 changesets with 1 changes to 1 files (+1 heads)(run 'hg heads' to see heads, 'hg merge' to merge)
- If the pull add no new HEAD in your repo, a simple update is enough
3.理解三
问题:
We started using Mercurial a several weeks ago. Most developers follow this workflow:
- work on a feature
- commit -m "Worked on feature ABC"
- pull -u
- If branch
- merge
- commit -m "Merge"
- push
Today, one of our developer suggested that we do:
- work on a feature
- pull -u
- if branch
- merge
- commit -m "Worked on feature ABC"
- push
That way, we have a lot less "Merge" changesets in the log.
Some of us think it's just a matter preference. Some of us think one is better than the other. We don't have much experience and don't want to live the downsides of misusing the tool. So if one approach is more advisable then the other, please let me know why.
解答:
I like your original procedure more, but reasonable people can certainly disagree. I consider merging an actual piece of software development work and like having it be a first class citizen in our process.
In your second/suggested procedure the risk is that the pull does some stuff you really don't want and then you have a very hard time separating it from the work you've already done.
For people who just can't stand branchy history the usual preferred workflow is:
- work on a feature
- commit
- pull --rebase
- push
where the --rebase
option appears on pull after you enable the rebase extension. I'm not a fan of rebase because it's technically rewriting history which is antithetical to how mercurial is supposed to work, but I'm in a rapidly shrinking minority on that point.
Bottom line, if you really don't want a branchy history use rebase -- don't update into uncommitted changes as it's hard to undo.
- hg 的 merge 和 update 的区别
- hg 的revert 和 update 的区别
- merge和update的区别
- Hibernate的update()和merge()的区别
- Hibernate update 和 merge 的区别
- hibernate merge和update的区别
- hibernate中update和merge的区别
- Session中merge和update的区别
- Hibernate中update()和merge()的区别
- Hibernate update 和 merge 、saveOrUpdate的区别
- Mercurial 、tortoisehg、 hg serve、hg web的区别和介绍
- hg 的update 和 pull 操作的不同
- Hibernate中saveOrUpdate、update和merge的区别
- hibernate笔记-014-merge和update的区别
- merge、update和saveOrUpdate的差别
- 例说hg(二)———— hg merge的用法
- Hibernate的merge与update方法的区别
- Hibernate的merge与update方法的区别
- Eclipse的project explorer 下的项目名称字体设置
- 动画里关于 CALayer 的一些零碎知识点
- 认识自己——恐惧的奴隶7:高中
- CSS对浏览器的兼容性
- vim 配置及先过关命令
- hg 的 merge 和 update 的区别
- Universal ImageLoader 在ListView刷新时会闪动
- MyBatis+Spring+MySql
- Dart基础-控制流程与异常处理
- Thrift TThread
- MySQL高可用性之Keepalived+Mysql(双主热备)
- 一个人生活,如何摆脱孤独提升幸福感?
- 图像处理之Mean Shift滤波(边缘保留的低通滤波)
- 气管瘢痕狭窄的治疗方法都有哪些?