Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 455047
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T22:19:53+00:00 2026-05-12T22:19:53+00:00

I have a number of branches in a git repository: david@Panama ~/app: git branch

  • 0

I have a number of branches in a git repository:

david@Panama ~/app: git branch -r  
origin/HEAD -> origin/master
origin/master
origin/newButtons
origin/newFonts
origin/serverView

If I try and import this git repo into mercurial:

david@Panama ~/: hg convert app
...
david@Panama ~/app-hg: hg update
388 files updated, 0 files merged, 0 files removed, 0 files unresolved
david@Panama ~/app-hg: hg branches
default                     1148:6d04af619607

It seems that the branches have been "lost" (in terms of them no longer being separated) and indeed merged into the tip:

david@Panama ~/app-hg: hg log
changeset:   1148:6d04af619607
tag:         tip
user:        convert-repo
date:        Mon Nov 16 17:57:06 2009 +0000
summary:     update tags

changeset:   1147:742e7a01a6c9
parent:      1144:bff259181b22
user:        user1
date:        Sat Nov 14 17:47:09 2009 +0000
summary:     Playing around with fonts to get a cleaner look

changeset:   1146:162c1b0dd648
parent:      1144:bff259181b22
user:        user1
date:        Fri Nov 13 21:12:21 2009 +0000
summary:     Playing with new server view

changeset:   1145:aa06857832ab
user:        user1
date:        Sat Nov 14 13:54:12 2009 +0000
summary:     Updated buttons to something more fitting

changeset:   1144:bff259181b22
user:        David Mytton <>
date:        Fri Nov 13 10:35:51 2009 +0000
summary:     Example

Given that being the case:

a) Am I doing something wrong to import the branches here?

b) Can the branches actually be imported?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T22:19:53+00:00Added an answer on May 12, 2026 at 10:19 pm

    This is by design. Imported Git branches are only labeled in Mercurial, and hg heads should give you the correct number of imported “branches”.

    As mentioned in this thread:

    Consider a tree that looks like this:

            o-o-o-o-o-o-b <- branch foo
           /
     -o-o-a
           \
            o-o-c <- branch bar
    

    What branch are “a” and its ancestors on?
    We haven’t the slightest clue. In fact, the only changesets we have any certainty about are b nd c because branch names aren’t part of history.

    So:

    Turns out it’s actually impossible to do this right, because git doesn’t store enough information.
    Consider a repo with two branches in git, each with a number of commits.
    Because git doesn’t record which branch each commit originated on, there isn’t enough information in the tree to label each changeset.
    A git user can swap the names of the two branches and nothing is recorded to say it was ever different. If two branches have a common ancestor (and they almost certainly will),
    what branch is that ancestor on? We don’t know.

    The best we can do in the general case is to label each branch head as being on that branch. Then if you do an incremental conversion, we’ll probably do the right thing. But git’s concept of branches aren’t a perfect match to hg’s so this conversion won’t be perfect either.


    You can test it with a small Git repo (Git 1.6.5.1, Hg1.3.1):

    PS C:\Prog\Git\tests> cd .\hgimport
    PS C:\Prog\Git\tests\hgimport> git init gitRepoToImport
    PS C:\Prog\Git\tests\hgimport> cd .\gitRepoToImport
    PS [...]\gitRepoToImport> echo firstContentToBr1 > br1.txt
    PS [...]\gitRepoToImport> echo firstContentToBr2 > br2.txt
    PS [...]\gitRepoToImport> echo firstContentToBr3 > br3.txt
    PS [...]\gitRepoToImport> git add -A
    PS [...]\gitRepoToImport> git commit -a -m "first content, to be evolved in three different branches"
    

    Make a bunch of modifications in three separate branches:

    PS [...]\gitRepoToImport> git checkout -b br1
    PS [...]\gitRepoToImport> echo firstEvolutionInBr1 >> .\br1.txt
    PS [...]\gitRepoToImport> git commit -a -m "first evolution in branch 1"
    PS [...]\gitRepoToImport> echo secondEvolutionInBr1 >> .\br1.txt
    PS [...]\gitRepoToImport> git commit -a -m "second evolution in branch 1"
    PS [...]\gitRepoToImport> git checkout master
    PS [...]\gitRepoToImport> git checkout -b br2
    PS [...]\gitRepoToImport> echo firstEvolutionInBr1 >> .\br2.txt
    PS [...]\gitRepoToImport> git commit -a -m "first evolution in branch 2"
    PS [...]\gitRepoToImport> git checkout master
    PS [...]\gitRepoToImport> git checkout -b br3
    PS [...]\gitRepoToImport> echo firstEvolutionInBr3 >> .\br3.txt
    PS [...]\gitRepoToImport> git commit -a -m "first evolution in branch 3"
    PS [...]\gitRepoToImport> echo secondEvolutionInBr3 >> .\br3.txt
    PS [...]\gitRepoToImport> git commit -a -m "second evolution in branch 3"
    PS [...]\gitRepoToImport> echo thirdEvolutionInBr3 >> .\br3.txt
    PS [...]\gitRepoToImport> git commit -a -m "third evolution in branch 3"
    PS [...]\gitRepoToImport> git checkout br2
    PS [...]\gitRepoToImport> echo secondEvolutionInBr2 >> .\br2.txt
    PS [...]\gitRepoToImport> git commit -a -m "second evolution in branch 2"
    PS [...]\gitRepoToImport> git checkout br1
    PS [...]\gitRepoToImport> echo thirdEvolutionInBr3 >> .\br1.txt
    PS [...]\gitRepoToImport> git commit -a -m "third evolution in branch 1"
    PS [...]\gitRepoToImport> git checkout br2
    PS [...]\gitRepoToImport> echo thirdEvolutionInBr3 >> .\br2.txt
    PS [...]\gitRepoToImport> git commit -a -m "third evolution in branch 2"
    

    Then clone that Git repo (just in case, to male other tests)

    PS [...]\gitRepoToImport> cd ..
    PS C:\Prog\Git\tests\hgimport> git clone .\gitRepoToImport gitRepoToImport1
    

    Configure your ~/.hgrc with a format UTF-8 without BOM (took me a while to get it right!)

    [extensions]
    hgext.convert = 
    

    Then make the conversion

    PS C:\Prog\Git\tests\hgimport> hg convert .\gitRepoToImport1 hgRepo
    PS C:\Prog\Git\tests\hgimport> cd .\hgRepo
    PS C:\Prog\Git\tests\hgimport\hgRepo> hg heads
    

    You will get the three expected “branches”

    changeset:   9:ad0884395ada
    tag:         tip
    user:        VonC
    date:        Mon Nov 16 21:45:35 2009 +0100
    summary:     third evolution in branch 2
    
    changeset:   6:854bc6537c7c
    user:        VonC
    date:        Mon Nov 16 21:45:19 2009 +0100
    summary:     third evolution in branch 1
    
    changeset:   3:9194cf25d3ca
    user:        VonC
    date:        Mon Nov 16 21:44:09 2009 +0100
    summary:     third evolution in branch 3
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Git repository with many branches, some of them already merged and
I'm currently using git-bzr-ng to import a number of branches from a bzr repository
I have just created a new Git repository backed by Subversion, using git svn.
We have a subversion repository with top-level projects, each projects with trunk/branches/tags. And now
I've inherited a project and we are using git. We have a number of
I have a large number of projects setup in Git that were previously managed
I'm struggling to understand something about GIT. We've got a repository with a number
I have a repository which has two branches, default and BranchA . The graph
I have moved an SVN repo to Git and probably due to a number
I have two service pack branches coming out of one ‘main’ branch in TFS

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.