当您的工作副本发生更改时进行 hg update 是一个坏主意吗?

发布于 2024-08-28 23:17:52 字数 84 浏览 1 评论 0原文

看起来如果你先提交然后合并会更好。我有点惊讶的是,当您的工作副本发生更改时,甚至允许更新。在这种情况下允许更新是否可以避免由合并产生的具有两个父项的提交?

Seems like it would be better if you did commit followed by merge. I'm a little surprised update'ing is even allowed when your working copy has changes. Is allowing updates in such cases to avoid having commits that have two parents, which result from a merge?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

め可乐爱微笑 2024-09-04 23:17:52

我相信 hg update 会尝试合并您未提交的更改:

当工作目录包含未提交的更改时,以下规则适用:

  1. 如果 -c/--check-C/--clean 均未指定,并且:
    如果请求的变更集是工作目录父级的祖先或后代,则未提交的变更将合并到请求的变更集中,并且合并的结果保持未提交状态。
    如果请求的变更集不是祖先或后代(即,它位于另一个分支上),则更新将中止并保留未提交的更改。
  2. 使用-c/--check选项,更新将中止并保留未提交的更改。
  3. 使用-C/--clean选项,未提交的更改将被丢弃,工作目录将更新为请求的更改集。

这将避免对仅更新工作目录的操作(hg update)进行不必要的提交(在 .hg 存储库中注册)。

I believe hg update will try to merge your uncommitted changes:

The following rules apply when the working directory contains uncommitted changes:

  1. If neither -c/--check nor -C/--clean is specified, and:
    if the requested changeset is an ancestor or descendant of the working directory's parent, the uncommitted changes are merged into the requested changeset and the merged result is left uncommitted.
    If the requested changeset is not an ancestor or descendant (that is, it is on another branch), the update is aborted and the uncommitted changes are preserved.
  2. With the -c/--check option, the update is aborted and the uncommitted changes are preserved.
  3. With the -C/--clean option, uncommitted changes are discarded and the working directory is updated to the requested changeset.

That will avoid an unnecessary commit (registered in the .hg repo) for an operation (hg update) which only is about updating your working directory.

戒ㄋ 2024-09-04 23:17:52

Mercurial 鼓励记录项目的所有历史记录。如果您已经在工作目录中完成了一些工作,为什么不提交这些更改,提供对结果的有意义的描述作为提交消息,然后将结果合并到主分支中?其他人会更清楚地在两个单独的变更集中看到您为正常工作所做的工作以及您为解决合并冲突所做的工作。

通常,额外的合并更改集是可以的,但有时您只想在提交之前在主分支之上重新调整当前更改的基础。您可以查看rebase扩展。新的 hg rebase 命令允许您对已提交的更改进行变基。

Mercurial encourages recording all the history of a project. If you've done some work in your working directory, why not to commit these changes providing a meaningful description of your results as a commit message and then merge your results into the main branch? It will be more clear for other people to see in two separate changesets what you have made as your normal work and what you have made just for resolving merge conflicts.

Usually an extra merge changeset is OK, but sometimes you just want to rebase your current changes on top of the main branch before committing them. You might take a look at the rebase extension. The new hg rebase command allows you to rebase already committed changeses.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文