Mercurial 是否与 git clean 等效?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2760283/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 04:15:53  来源:igfitidea点击:

Does Mercurial have an equivalent to git clean?

gitmercurial

提问by Erik B

hg clean does not seem to exist, which kinda bothers me. Is this a feature that Mercurial doesn't have or did they just name it differently?

hg clean 似乎不存在,这有点困扰我。这是 Mercurial 没有的功能还是他们只是命名不同?

回答by Tim Henigan

There is no equivalent to git cleanin the core Mercurial package.

git clean核心 Mercurial 包中没有等效项。

However, the hg purgeextension does what you are after.

但是,hg purge扩展程序可以满足您的需求。

There is an open issueto make this extension part of the core package.

有一个未解决的问题使这个扩展成为核心包的一部分。

回答by Anup Kattel

The extension is already included in mercurial, but you still have to activate it.

该扩展已经包含在 mercurial 中,但您仍然需要激活它。

It's as simple as creating a .hgrc file in your home directory (e.g. Win 7: C:\Users\?yourusername?\.hgrc) and adding the following content to that file:

就像在您的主目录(例如 Win 7:)中创建一个 .hgrc 文件C:\Users\?yourusername?\.hgrc并将以下内容添加到该文件中一样简单:

[extensions] 
purge =

(Home directory is ~/.hgrcfor most other desktop operating systems (Unix, Gnu/Linux, Mac osx, BSD, etc.)

(主目录~/.hgrc用于大多数其他桌面操作系统(Unix、Gnu/Linux、Mac osx、BSD 等)

回答by Shane Holloway

I don't use git for my repository management. However, if I were to guess, I think hg purgemight be what you are seeking.

我不使用 git 进行存储库管理。但是,如果我猜测,我认为hg purge可能是您正在寻找的。

回答by cforbish

If you are on a linux based system (or Windows cygwin) you can:

如果您使用的是基于 linux 的系统(或 Windows cygwin),您可以:

hg status | grep "^?" | xargs rm -rf

If this works you can put this in your ~/.hgrc:

如果这有效,你可以把它放在你的 ~/.hgrc 中:

[alias]
clean = !hg status | grep "^?" | xargs rm -rf

Then simply run:

然后只需运行:

hg clean

I tested this on windows using cygwin (should work on linux).

我使用 cygwin 在 windows 上测试了这个(应该在 linux 上工作)。