简体   繁体   中英

Converting hg bookmarks to named branches

After migrating from git to mercurial (not my personal preference :) I have faced a problem: hg convert converts git branches to bookmarks. Is there a way to convert the bookmarks to named hg branches? Is it even required or not, and why? Thank you!

Git branches and hg bookmarks are essentially the same thing (a reference to a single changeset) which is why they've been converted that way. Bookmarks behave pretty much identically to git branches - they advance as you commit, etc (there's no concept of tracking branches, but you can get similar results using the remotebranches extension). Many people don't use named branches at all in Mercurial - they use bookmarks and/or anonymous branches.

Hg named branches are very different - the name is an indelible part of the history. It is not possible to (automatically) convert a git branch to an hg named branch because the git branch only names the tip of the branch - you have no way of knowing what other changesets should be part of the branch.

If you really want to use named branches from now on (and I strongly encourage it - I personally much prefer to have each task done in a separate named branch) I would suggest just starting a named branch with the same name at each current bookmark (you could then delete the bookmark).

You could manually go through and transplant or graft the changesets into new named branches, but doing so would remove the association with the git changeset - important if you're using hg-git rather than convert. Although graft may keep some association since it is implemented using the hg merge facilities.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM