Mercurial:选择文件的 qrefresh
假设我已经更改了许多文件,这样当我执行 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
由于
hg qrefresh
将自动包含所有更改,因此您只需排除某些文件,刷新实际上会从补丁中删除这些文件的所有更改。然后您可以恢复文件。这将刷新补丁中除
file1
和file3
之外的所有内容(补丁现在不包含任何更改):现在
file1
和file3< /code> 仍有一些更改,需要恢复:
这会将当前版本更改为
../../file1.orig
和../../file3.orig< /code>,以防万一您发现需要再次改变。您还可以添加
--no-backup
开关,这样就不会创建这些开关。您也可以按相反的顺序执行此操作:
这次刷新不需要参数,因为与工作目录的父目录相比,这两个文件没有变化,因此将从补丁中消失(基本上刷新补丁重新编写补丁)。我就是这样做的,但我还想演示
-X
开关。查看
hg help revert
和hg 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
andfile3
in the patch (the patch now contains no changes of either):Now
file1
andfile3
still have some changes and need to be reverted: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:
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
andhg help qrefresh
for more.