Does Mercurial have an equivalent to git clean?

旧巷老猫 提交于 2019-12-20 10:59:36

问题


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?


回答1:


There is no equivalent to git clean in the core Mercurial package.

However, the hg purge extension does what you are after.

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




回答2:


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

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:

[extensions] 
purge =

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




回答3:


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




回答4:


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

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

If this works you can put this in your ~/.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).



来源:https://stackoverflow.com/questions/2760283/does-mercurial-have-an-equivalent-to-git-clean

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!