放弃所有并获得最新版本的干净副本?
我正在移动构建过程以使用 Mercurial,并希望将工作目录恢复到提示修订版的状态。构建过程的早期运行将修改一些文件并添加一些我不想提交的文件,因此我有本地更改和未添加到存储库的文件。
放弃所有这些并获得具有最新版本的干净工作目录的最简单方法是什么?
目前我正在这样做:
hg revert --all
<build command here to delete the contents of the working directory, except the .hg folder.>
hg pull
hg update -r MY_BRANCH
但似乎应该有一个更简单的方法。
我想做相当于删除存储库、进行新克隆和更新的操作。但回购太大了,速度不够快。
I'm moving a build process to use mercurial and want to get the working directory back to the state of the tip revision. Earlier runs of the build process will have modified some files and added some files that I don't want to commit, so I have local changes and files that aren't added to the repository.
What's the easiest way to discard all that and get a clean working directory that has the latest revision?
Currently I'm doing this:
hg revert --all
<build command here to delete the contents of the working directory, except the .hg folder.>
hg pull
hg update -r MY_BRANCH
but it seems like there should be a simpler way.
I want to do the equivalent of deleting the repo, doing a fresh clone, and an update. But the repo is too big for that to be fast enough.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
这些步骤应该可以缩短为:
-C
标志告诉更新命令在更新之前放弃所有本地更改。但是,这可能仍会在您的存储库中留下未跟踪的文件。听起来您也想摆脱这些,所以我将使用 purge 扩展来实现这一点:
在任何情况下,没有一个命令可以让 Mercurial 执行来完成所有操作你想要在这里,除非你将过程更改为你说你不能做的“完整克隆”方法。
Those steps should be able to be shortened down to:
The
-C
flag tells the update command to discard all local changes before updating.However, this might still leave untracked files in your repository. It sounds like you want to get rid of those as well, so I would use the
purge
extension for that:In any case, there is no single one command you can ask Mercurial to perform that will do everything you want here, except if you change the process to that "full clone" method that you say you can't do.
这将删除所有更改并更新到当前分支中的最新头。
您还可以打开清除扩展,以便也能够删除所有未版本控制的文件。
This will remove all the changes and update to the latest head in the current branch.
And you can turn on purge extension to be able to remove all unversioned files too.
要在没有清除扩展的情况下删除 *nix 上未跟踪的内容,您可以使用
Which is using
To delete untracked on *nix without the purge extension you can use
Which is using
hg status将显示所有新文件,然后您可以rm它们。
通常我想摆脱被忽略和未版本化的文件,所以:
然后遵循:
这将所有版本化文件置于正确的状态以进行修订 xxxx
遵循 Stack Overflow 的传统,告诉您您不想这样做对此,我经常发现这个“核选项”毁掉了我关心的东西。
正确的方法是在构建过程中有一个“make clean”选项,也许还有“make realclean”和“make distclean”。
hg status will show you all the new files, and then you can just rm them.
Normally I want to get rid of ignored and unversioned files, so:
And then follow that with:
which puts all the versioned files in the right state for revision xxxx
To follow the Stack Overflow tradition of telling you that you don't want to do this, I often find that this "Nuclear Option" has destroyed stuff I care about.
The right way to do it is to have a 'make clean' option in your build process, and maybe a 'make reallyclean' and 'make distclean' too.
如果您正在寻找一种简单的方法,那么您可能想尝试一下。
我自己几乎记不清所有工具的命令行,所以我倾向于使用 UI:
1。首先,选择“提交”
2.然后,显示忽略的文件。如果您有未提交的更改,请将其隐藏。
3.现在,选择所有这些,然后单击“删除未版本化”。
完成。这个过程比命令行的东西更容易记住。
If you're looking for a method that's easy, then you might want to try this.
I for myself can hardly remember commandlines for all of my tools, so I tend to do it using the UI:
1. First, select "commit"
2. Then, display ignored files. If you have uncommitted changes, hide them.
3. Now, select all of them and click "Delete Unversioned".
Done. It's a procedure that is far easier to remember than commandline stuff.