hg 相当于 git add -p?

发布于 2024-12-09 23:27:13 字数 194 浏览 0 评论 0原文

是否有与 git add -p 等价的 Mercurial 版本?

引用 man 的话,带有选项 -p (或 --patch)的 git-add 会执行以下操作:

在索引和工作之间交互式选择补丁块 树并将它们添加到索引中。这使用户有机会 在将修改的内容添加到索引之前检查差异。

Is there a mercurial equivalent of git add -p?

Quoting from man, git-add with the option -p (or --patch) does the following:

Interactively choose hunks of patch between the index and the work
tree and add them to the index. This gives the user a chance to
review the difference before adding modified contents to the index.

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

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

发布评论

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

评论(4

離人涙 2024-12-16 23:27:13

查看记录扩展(与 Mercurial 捆绑在一起)。

请注意,由于 Mercurial 没有像 git 这样的暂存区域的概念,因此运行 hg record 只会让您逐块检查工作副本中的修改。您选择记录的任何更改都将被提交,而您选择不记录的任何更改将仅作为修改保留在工作副本中。

Have a look at the record extension (which comes bundled with Mercurial).

Note that since Mercurial doesn't have the concept of the staging area like git, running hg record will simply allow you to examine, hunk by hunk, the modifications in your working copy. Any changes you choose to record will be committed, and any changes you choose not to record are simply left as modifications in your working copy.

空心↖ 2024-12-16 23:27:13

记录扩展 是执行此操作的标准工具。它允许您选择要包含或不包含在提交中的帅哥。一旦您在 hgrc 中启用了扩展程序,命令就是

hg record

CRecord Extension 给出在此之上有一个 TUI(文本用户界面),它允许您深入了解要包含的行。但这不是标准的,因此需要先将其下载到目录,然后才能在 hgrc 中启用它。

hg crecord

编辑:

  1. 大约 v3.4。现在支持各种命令
    -i--interactive 标志。例如:

    <前><代码>hg commit -i

    ...会逐个询问您要包含的内容。

  2. CRecord 将其作为核心功能引入到 3.8 中。将以下内容添加到您的
    .hgrc

    <前><代码>[ui]
    接口=诅咒

    现在,--interactive 命令将显示与旧版相同的界面
    CRecord 扩展名。

The Record Extension is the standard tool for this. It allows you to pick hunks to include or not in a commit. Once you've enabled the extension in your hgrc, the command is just

hg record

The CRecord Extension gives you a TUI (Text User Interface) on top of this which allows you to go down to which lines you want to include. This isn't standard though, so it need downloading to a directory before you can enable it in your hgrc.

hg crecord

Edit:

  1. The Record extension is no longer necessary since approx v3.4. Now various commands support
    the -i or --interactive flag. For example:

    hg commit -i
    

    ...will ask you hunk by hunk what you want to include.

  2. CRecord made it in to 3.8 as a core feature. Add the following to your
    .hgrc

    [ui]
    interface = curses
    

    Now, --interactive commands will bring up the same interface as the old
    CRecord extension.

彩扇题诗 2024-12-16 23:27:13

从 Mercurial 3.8.1 开始,crecord 扩展是内置的。确保 .hgrc 中的“ui”部分包含 interface =curses,否则您会得到一个不舒服的问答界面。

[ui]
interface = curses

然后以交互方式进行提交,询问您要在该提交中包含哪个块或哪一行。

hg commit --interactive

As of Mercurial 3.8.1 the crecord extension is builtin. Make sure the “ui” section in your .hgrc contains interface = curses, or you get an uncomfortable question-and-answer-interface.

[ui]
interface = curses

Then do your commits interactively to be asked about which hunk—or—which line you want to include in that commit.

hg commit --interactive
无畏 2024-12-16 23:27:13

如果您使用 TortoiseHg,它具有 Shelve 功能,允许您存储不想提交到临时区域的更改。它允许块选择,就像 git 一样。

在TortoiseHg Workbench中,可以通过两种方式访问​​该工具:

  1. 点击Repository ->搁置
  2. Commit 窗口中,选择搁置工具图标。它看起来像这样:

在此处输入图像描述

If you are using TortoiseHg, it has a Shelve feature which allows you to store changes you don't want to commit to a temporary area. It allows hunk selection, just like git.

In the TortoiseHg Workbench, this tool can be accessed in 2 ways:

  1. Click Repository -> Shelve
  2. In Commit window, select the shelve tool icon. It looks like this:

enter image description here

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