Hg (Mercurial): any way to “set aside” the working copy for later?

社会主义新天地 提交于 2019-11-30 07:21:21

Don't worry about "the fear of two heads". Two heads is a very normal state. It's called anonymous branches, and it's one of the ways people do temporary branches in Mercurial.

Just commit, and then update to tip-1 and you're ready to go:

hg commit -m "working on XXX"
hg update -r "tip-1"

and away you go. If you want to drop a bookmark (less permanent than a tag) on that head you can, but there's no need to worry about it.

You can always push one head without pushing another using hg push -r HEAD where that can even be hg push -r .

Don't fear heads -- they're what makes a DAG based VCS powerful.

You can do this with the mq, attic or shelve extensions.

  1. Assign a tag to your refactor revision
  2. Commit the tag
  3. Clone the repository again
  4. Revert to the stable version
  5. Work from the stable version
  6. Don't worry about multiple heads, you can easily merge later

Since mercurial uses hard links, you can keep both repositories on your local machine with minimal space used. commands:

$hg tag Refactor
$cd ..
$hg clone Refactor Stable
$cd Stable
$hg revert -r REVISION_NUMBER

extra help:
http://hgbook.red-bean.com/
http://kiln.stackexchange.com/

You can do it the simple way:

$ hg diff -g > tmp
$ hg revert --all

Your changes will now be stored in tmp. You can restore them with

$ hg patch --no-commit tmp

and you'll be back where you were. There are extensions like shelve that automates the above for you.

In git you would do a 'stash'. According to This hg has 'shelve', but it requires an extension.

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