放弃所有并获得最新版本的干净副本?

发布于 2024-10-16 23:07:03 字数 401 浏览 2 评论 0原文

我正在移动构建过程以使用 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 技术交流群。

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

发布评论

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

评论(5

本宫微胖 2024-10-23 23:07:04

这些步骤应该可以缩短为:

hg pull
hg update -r MY_BRANCH -C

-C 标志告诉更新命令在更新之前放弃所有本地更改。

但是,这可能仍会在您的存储库中留下未跟踪的文件。听起来您也想摆脱这些,所以我将使用 purge 扩展来实现这一点:

hg pull
hg update -r MY_BRANCH -C
hg purge

在任何情况下,没有一个命令可以让 Mercurial 执行来完成所有操作你想要在这里,除非你将过程更改为你说你不能做的“完整克隆”方法。

Those steps should be able to be shortened down to:

hg pull
hg update -r MY_BRANCH -C

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:

hg pull
hg update -r MY_BRANCH -C
hg purge

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.

猛虎独行 2024-10-23 23:07:04
hg up -C

这将删除所有更改并更新到当前分支中的最新头。

您还可以打开清除扩展,以便也能够删除所有未版本控制的文件。

hg up -C

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.

深居我梦 2024-10-23 23:07:04

要在没有清除扩展的情况下删除 *nix 上未跟踪的内容,您可以使用

hg pull
hg update -r MY_BRANCH -C
hg status -un|xargs rm

Which is using

update -r --rev REV 修订版

update -C --clean 放弃未提交的更改(无备份)

status -u --unknown 仅显示未知(未跟踪)文件

status -n --no-status 隐藏状态前缀

To delete untracked on *nix without the purge extension you can use

hg pull
hg update -r MY_BRANCH -C
hg status -un|xargs rm

Which is using

update -r --rev REV revision

update -C --clean discard uncommitted changes (no backup)

status -u --unknown show only unknown (not tracked) files

status -n --no-status hide status prefix

乖乖哒 2024-10-23 23:07:04

hg status将显示所有新文件,然后您可以rm它们。

通常我想摆脱被忽略和未版本化的文件,所以:

hg status -iu                          # to show 
hg status -iun0 | xargs -r0 rm         # to destroy

然后遵循:

hg update -C -r xxxxx

这将所有版本化文件置于正确的状态以进行修订 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:

hg status -iu                          # to show 
hg status -iun0 | xargs -r0 rm         # to destroy

And then follow that with:

hg update -C -r xxxxx

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.

岛徒 2024-10-23 23:07:04

如果您正在寻找一种简单的方法,那么您可能想尝试一下。

我自己几乎记不清所有工具的命令行,所以我倾向于使用 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"

Commit

2. Then, display ignored files. If you have uncommitted changes, hide them.

Show ignored files

3. Now, select all of them and click "Delete Unversioned".

Delete them

Done. It's a procedure that is far easier to remember than commandline stuff.

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