How to tag and go to a tag in hg

23,107

Solution 1

Tags are not branches. Tags are markers for a particular commit - basically, a way to name commits. That's all. You don't "switch a repository to a tag" any more than you would "switch a repository to a commit" - you can check out a tag, but all that does is roll back your working copy to the corresponding changeset which was tagged.

Branches are created automatically in Mercurial when you commit code that doesn't directly build off of the current head revision.

See here for some more details:

https://www.mercurial-scm.org/wiki/Tag

https://www.mercurial-scm.org/wiki/Branch

Solution 2

Just update to the tag name.

hg tag 1.0
... make changes ...
hg ci
hg up 1.0
Share:
23,107
michael
Author by

michael

Updated on July 05, 2022

Comments

  • michael
    michael almost 2 years

    This website says hg tag 1.0 is to get my Mercurial repository to a tag name.

    How can I switch my repository to that tag name?

    $ hg tag myTag1.0
    $ <edit more files>
    $ hg commit -m "a message"
    $ hg how to go back to that tag?
    

    And if I make a new hg commit here, what will happen? Will it go to the branch of myTag1.0? Or will it stay on the default branch?

  • bobpaul
    bobpaul over 13 years
    The problem with this is that tags are committed as changes to the .hgtags file. So like this: Changeset: 350:e6e05f8b7536 tag: tip description: added tag 1.0 for changset 5d0862b8c30b Changeset 349:5d0862b8c30b tag: 1.0 description: Fixed bugs X and Y, 1.0 pending testing. But now when you hg up 1.0, the tags don't exist, so any commit here will create a branch (new head) where 1.0 is not tagged. Not so much a problem, but something you must be aware of.