hg 相当于 git add -p?
是否有与 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
查看记录扩展(与 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.记录扩展 是执行此操作的标准工具。它允许您选择要包含或不包含在提交中的帅哥。一旦您在 hgrc 中启用了扩展程序,命令就是
CRecord Extension 给出在此之上有一个 TUI(文本用户界面),它允许您深入了解要包含的行。但这不是标准的,因此需要先将其下载到目录,然后才能在 hgrc 中启用它。
编辑:
自 大约 v3.4。现在支持各种命令
-i
或--interactive
标志。例如:<前><代码>hg commit -i
...会逐个询问您要包含的内容。
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
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.
Edit:
The Record extension is no longer necessary since approx v3.4. Now various commands support
the
-i
or--interactive
flag. For example:...will ask you hunk by hunk what you want to include.
CRecord made it in to 3.8 as a core feature. Add the following to your
.hgrc
Now,
--interactive
commands will bring up the same interface as the oldCRecord extension.
从 Mercurial 3.8.1 开始,crecord 扩展是内置的。确保
.hgrc
中的“ui”部分包含interface =curses
,否则您会得到一个不舒服的问答界面。然后以交互方式进行提交,询问您要在该提交中包含哪个块或哪一行。
As of Mercurial 3.8.1 the crecord extension is builtin. Make sure the “ui” section in your
.hgrc
containsinterface = curses
, or you get an uncomfortable question-and-answer-interface.Then do your commits interactively to be asked about which hunk—or—which line you want to include in that commit.
如果您使用 TortoiseHg,它具有
Shelve
功能,允许您存储不想提交到临时区域的更改。它允许块选择,就像 git 一样。在TortoiseHg Workbench中,可以通过两种方式访问该工具:
Repository ->搁置
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:
Repository -> Shelve
Commit
window, select the shelve tool icon. It looks like this: