Mercurial:选择文件的 qrefresh

发布于 2024-11-26 22:56:26 字数 249 浏览 0 评论 0原文

假设我已经更改了许多文件,这样当我执行 hg status 时,它会出现类似以下内容:

M ../../file1
M ../../file2
M ../../file3

如果我只想对我对 file2 所做的更改执行 qrefresh 并隐式放弃我已经更改的更改,该怎么办?对 file1 和 file3 进行操作以使它们恢复到原始状态?有没有办法用 Mercurial 做到这一点?我对整个版本控制的事情相当陌生。

Say I have a number of files I have changed such that when I do an hg status it comes up with something like:

M ../../file1
M ../../file2
M ../../file3

What if I only want to do a qrefresh for the changes I've made for file2 and implicitly abandon changes I've made to file1 and file3 such that they are reverted to their original state? Is there a way to do that with mercurial? I'm fairly new to the whole version control thing.

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

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

发布评论

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

评论(1

何以心动 2024-12-03 22:56:26

由于 hg qrefresh 将自动包含所有更改,因此您只需排除某些文件,刷新实际上会从补丁中删除这些文件的所有更改。然后您可以恢复文件。

这将刷新补丁中除 file1file3 之外的所有内容(补丁现在不包含任何更改):

hg qrefresh -X ../../file1 -X ../../file3

现在 file1file3< /code> 仍有一些更改,需要恢复:

hg revert ../../file1 ../../file3

这会将当前版本更改为 ../../file1.orig../../file3.orig< /code>,以防万一您发现需要再次改变。您还可以添加 --no-backup 开关,这样就不会创建这些开关。

您也可以按相反的顺序执行此操作:

hg revert ../../file1 ../../file3
hg qrefresh

这次刷新不需要参数,因为与工作目录的父目录相比,这两个文件没有变化,因此将从补丁中消失(基本上刷新补丁重新编写补丁)。我就是这样做的,但我还想演示 -X 开关。

查看 hg help reverthg help qrefresh 了解更多信息。

Since hg qrefresh will automatically include all changes, you only need to exclude certain files, and the refresh will actually drop all changes of those files from the patch. Then you can revert the files.

This refreshes everything but file1 and file3 in the patch (the patch now contains no changes of either):

hg qrefresh -X ../../file1 -X ../../file3

Now file1 and file3 still have some changes and need to be reverted:

hg revert ../../file1 ../../file3

This will change the current versions to ../../file1.orig and ../../file3.orig, just in case you find you need the changes again. You can also add the --no-backup switch and those won't be created.

You could also do this in the opposite order:

hg revert ../../file1 ../../file3
hg qrefresh

The refresh doesn't need arguments this time because it will see no changes in those 2 files compared to the parent of the working directory, and thus will disappear from the patch (refreshing the patch basically re-writes the patch). This is the way I would do it, but I also wanted to demonstrate the -X switch.

Check out hg help revert and hg help qrefresh for more.

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