How can I remove the working copy from a Mercurial clone?

痞子三分冷 提交于 2019-12-04 07:40:09

问题


When cloning a repository with mercurial you can pass the -U/--noupdate flag to create a clone with no working copy. Can I remove the working copy if I forget to pass this flag at clone time? And if so, how?

This is conceptually similar to this git question, but for mercurial.


回答1:


I might be missing the nuances here. Some one can correct me.

Documentation at Mercurial wiki says following about bare repositories:

"Although this is a minor issue, Mercurial can obviously handle a bare repository; that is, a repository without a working copy. In Git you need a configuration option for that, whereas in Hg you only need to check out the null revision, like this:"

hg update null

The null revision is empty state you have when you have just done hg init. It is the parent of revision 0 (and the second parent of all non-merge revisions) and by updating back to it you again get an empty working copy.

The link may look ironic:

  • https://www.mercurial-scm.org/wiki/GitConcepts



回答2:


rm -rf *

This removes all "visible" files (under *nix). Since the Mercurial repository is stored in the "hidden" file .hg, it won't be touched. Unfortunately, neither will any hidden files of your own, such as .hgignore.

To restore the working copy, I'm sure there's an hg update flag that works, but this will as well:

hg revert --all


来源:https://stackoverflow.com/questions/4158726/how-can-i-remove-the-working-copy-from-a-mercurial-clone

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