1

I want to convert a Mercurial project to a Git project. I am following the directions here https://stackoverflow.com/a/34853438/984003 using TortoiseHG.

  1. Enable hggit

  2. Open a command line, enter an empty directory.

  3. git init --bare .git

  4. cd to your Mercurial repository.

  5. hg bookmarks hg

  6. hg push c:/path/to/your/git/repo

  7. In the Git directory: git config --bool core.bare false

After the push command, it said

added 5815 commits with 24723 trees and 24178 blobs

So something happened. But, when I go to repo directory (the path that I pushed to), it's empty except for .git

user984003
  • 23,717
  • 51
  • 158
  • 250
  • Have you tried to checkout to some changeset? – zerkms Aug 29 '19 at 00:51
  • I'm completely new to Git, hence the conversion from Mercurial :) Checkout from where? – user984003 Aug 29 '19 at 00:52
  • @user984003 it's the same as in mercurial - you need to `git checkout` to a particular revision, check it with `git log` – zerkms Aug 29 '19 at 00:55
  • @torek hasn't they "unbare" it on the step 7? – zerkms Aug 29 '19 at 01:01
  • @zerkms There's no history, no version, no branches, nothing. – user984003 Aug 29 '19 at 01:03
  • @torek I just tried and it works to me :shrug: – zerkms Aug 29 '19 at 01:07
  • 1
    @zerkms: oh, I see what's going on here: the idea is to write the Git repository to `.git`, so that instead of `X.git`—which you'd then clone to `X` to create `X/.git`—you have something that, when you remove the bare-ness, is supposed to make its *parent* directory become the work-tree. That could actually work, if everything lines up just right. (I don't have TortoiseHG so I can't test these exact steps as shown.) – torek Aug 29 '19 at 01:14
  • @torek yep, there is a chance that's what OP might have been missing PS: I did not do all those steps, I made it up and I DID specify that `.git` manually (given I know it) :-D – zerkms Aug 29 '19 at 01:21

1 Answers1

1

@zerkmas was right in the comments.

From c:/path/to/your/git/repo, do:

git checkout hg

And then all the files appeared.

EDIT: In the end, this didn't work out for me either. It loses the branches.

I ended up using GitHub's importer:

Convert Bitbucket Mercurial repository to Git. Maintain branches and history. Online solution

user984003
  • 23,717
  • 51
  • 158
  • 250