`bookmarks` will do that. Or you can use unnamed heads and track them manually[0] (that's essentially what bookmarks — and git branches — do). "Detached heads" are not a thing in mercurial, heads don't have to be named.
[0] obviously there's nothing to track if you're just going on a short tangent, just commit your stuff, and go back to the original to merge if it was a good idea or forget if it was not. And yes you can create a bookmark "after the fact" e.g. do half a dozen commits, realise that it's going to take longer than you thought and create a bookmark for the current experiment on the tip.
It's a beautiful thing, really <tears up a bit..../>
In my opinion, this is not all good although it clearly solves a problem. Having two somewhat non-orthogonal features for branching undoes a part of the easier learning curve argument. You end up having to educate people whether to use bookmarks or branches and in what situations.
If branches are permanent, who are allowed to create branches? Everyone or just maintainers/core developers? What if a would-be contributor creates a branch that isn't wanted as a permanent branch or has a bad name? Need to rename a branch or do some tricks to comply with the upstream conventions? It ends up being a similar social/political issue to git rebase vs. git merge.
The easier learning curve argument was more relevant when people were coming to hg from svn/cvs backgrounds. These days more and more people are coming from a git background.
Like most things, it depends. But mostly no, it doesn't impact the learning curve issue, especially if your team uses the git branching model, you never even have to address Mercurials named branches.
I'd also say all the other advantages of Mercurial far out-weigh something a conceptually simple as "use bookmarks for git-like, non-permanent branches; use named branches for permanent branches." Done.
I don't know why git users get so hung up on named branches—you never have to use them if they don't make sense for your project.
[1] http://stevelosh.com/blog/2009/08/a-guide-to-branching-in-me...
As far as learning curve, the branch/bookmark confusion doesn't seem to be all that big in practice IMO.
Oddly enough, I find myself liking the simplicity of Git here. You can do pretty complex stuff with it, but having only one type of branch seems to help some. That, and the local-only stashsets, which seem to be intentionally kept as simple as possible. In Mercurial, you have named branches, unnamed branches, cloned repos, bookmarks, maybe some other stuff that I don't know about, and I'm not really sure how they all interact and what's used for what.
http://mercurial.selenic.com/wiki/ShelveExtension
It does pretty much exactly the same thing.
It's exactly the same thing git branches do. If it seems hacky, it's also hacky in git.
> At best, it would be as good as them, but then why not stick with the original?
Stick with what original? The originals in mercurial are branches (where the branch name is part of the commit metadata and thus of the repository's history forever, save for history rewriting) and "anonymous heads".
Then users clamoured for transient (movable, renamable, deletable) git-style branches, so bookmarks were added as an option.
> cloned repos
Erm… you can also clone repositories in git.
> I'm not really sure how they all interact
At the end of the day, it's all commit DAG.
I more meant that it seems hacky to add a feature that's mostly-sorta like Git branches to Mercurial now.
> Stick with what original? The originals in mercurial are branches (where the branch name is part of the commit metadata and thus of the repository's history forever, save for history rewriting) and "anonymous heads".
I meant original as in Git vs Mercurial. Like if you want Git-like branches, then why not just stick with Git?
> Erm… you can also clone repositories in git.
Yeah, you could, but I've never seen anybody recommend cloning a Git repo on the same computer for the purpose of separating out work from the main branch. At least for a while, this seemed to be widely recommended way of separating code out in Mercurial.
Where things get kinda weird - in Git, if you want to commit code somewhere that doesn't go into main just yet, there are only 2 options - branches and stash, and stash is explicitly meant to be a very short-term, local thing, since you can't really share them easily and they aren't really part of the commit hierarchy. That makes things simpler, as you never have to wonder what the right feature to use is for keeping separate work somewhere and sharing it with other people. You can create complex structures with branches, but at least there's only one 'type' of thing to keep track of.
I'm not as familiar with Mercurial, but for ways to keep temporary work somewhere, it seems we have named branches, anonymous branches, bookmarks, cloned repos on the same system, and apparently shelve too. According to this guy[1], the workflows for sharing bookmarks around don't seem to be fleshed out all that well either. So how do I know which one to use for what tasks?
[1] http://www.kevinberridge.com/2012/05/hg-bookmarks-made-me-sa...
That said, the handling of named branches remains a pain point, and at this point I would recommend people just go with Git despite the steeper learning curve.
Where Mercurial falls short to me is that if you create a branch in your main repository like that, then it never goes away as far as I can tell. What Mercurial really wants you to do is clone your repo, and do that work that would be a Git branch in the clone. But to do that, you have to start with a clean repo, actively decide you want to create a new branch/clone, clone your repo, and only then start doing that work in the clone. If you've already done some work, and then decided that a piece of it ought to be branched off, then your workflow is pretty messy - you have to clone with the work uncommitted, then manually move the changes over to the clone and commit them there. And switch any working directories you might have open to the clone directory to work in it.
Yeah, no thanks, I'll stick with Git.