I read http://stevelosh.com/blog/2009/08/a-guide-to-branching-in-mercurial/ where comparing with git for Anonymous branches shown:
Git has no real way to handle this. Sure, it lets you update and
commit, but if you don’t create a (named) ref to that new commit
you’re never going to find it again once you switch to another
one. Well, unless you feel like grep’ing through a bunch of log
output.
Oh, and hopefully it doesn’t get garbage collected.
Sometimes you might not want to think up a name for a quick-fix
branch. With git you have to name it if you want to really do
anything with it, with Mercurial you don’t.
So can I switch to intermediate project state (by git reset --hard 6aa32cfecf4
or something) and commit sequence of changes without taking name to branch?
hg heads
shown all heads including anonymous branches. Is this possible from CLI find all heads from these anonymous branches with git?
You can indeed switch to an intermediate project state, although you want to use
git checkout 6aa32cf
instead ofgit reset --hard
;git reset
will move the HEAD branch to that state, which is not what you want. git will warn you that you're in a "detached HEAD" state, which means that it doesn't know which branch to advance when you commit. You can certainly still work and commit, though.If you do make commits, and then checkout another branch without naming the branch you're on, git will warn you:
Even if you don't follow its instructions, you can still find the commit later with
git reflog show HEAD
andgrep
if you remember the commit message you're looking for:Or, even later, with
git fsck --unreachable --no-reflogs
and some scripting.