5

I have a HG project hosted on Bitbucket, and I want to move it to Github.

I have followed the guideline here to install hg-git extension, on my TortoiseHG.

I have created a repository on Github, but have not initialized it yet (it displays that instruction page), so I can't clone that git repository.

What do I go next?

EDIT: Sorry forgot to add that I will then use git from then on.

UPDATE: I borrowed a mac and converted it using fast-git-import painlessly. If anyone tried the solutions below and worked under Windows, vote it up enough, and I'll make it the answer.

Erick G. Hagstrom
  • 4,873
  • 1
  • 24
  • 38
lulalala
  • 17,572
  • 15
  • 110
  • 169

3 Answers3

3

Just found out my question is a duplicate of Converting a Mercurial (hg) repository to Git on Windows (7).

It works well. Since it is all under Cygwin there is no need to use pageant.

In addition to the answer to that question. I just need to generate a key under Cygwin using ssh-keygen -t rsa. I then copied the content of public key in .ssh/id_rsa.pub to Github repository setting.

I set the git origin to the Gihub address by git remote add origin (repo address). Then finally I can git push origin master --force onto Github.

Community
  • 1
  • 1
lulalala
  • 17,572
  • 15
  • 110
  • 169
2

You should complete the hg-git process (like an hg gexport) locally on your workstation.

Then, when you have a git repo mirroring your initial Hg repo, then you can add a GitHub origin, and push to it:

git remote add origin https://github.com/user/yourProject.git
git push origin master
git push --all

However, Lazy Badger comments, and rightly so, that the OP might want to only use Mercurial for this process, and not install Git at all.

In which case, the page "hg-git on GitHub" contains:

If you are starting from an existing Hg repository, you have to setup a Git repository somewhere that you have push access to, add it as default path or default-push path in your .hg/hgrc and then run hg push from within your project.
For example:

$ cd hg-git # (an Hg repository)
$ # edit .hg/hgrc and add the target git url in the paths section
$ hg push

This will convert all your Hg data into Git objects and push them up to the Git server.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • OP have **Mercurial, not git** – Lazy Badger Feb 20 '12 at 13:22
  • I tried `hg gexport` but `.git` folder was not created. The link you mentioned doesn't talk about `hg export`. Can you elaborate a bit more? – lulalala Feb 20 '12 at 13:24
  • @LazyBadger: OP has both if he/she wants to convert a Mercurial repo to a git one. – VonC Feb 20 '12 at 13:25
  • @lulalala: I was referring to `hg gexport` (`export` was a typo). But my point remains. You do the conversion locally, and then push your newly created repo to your (currently empty) GitHub repo. – VonC Feb 20 '12 at 13:26
  • @lulalala: see http://stackoverflow.com/questions/883452/git-interoperability-with-a-mercurial-repository for more on the `hg gexport` process. – VonC Feb 20 '12 at 13:28
  • @VonC - wrong, I have repo on Github, but use **only Mercurial**. *Never* make decision instead of author, if you aren't shaman or sensitive – Lazy Badger Feb 20 '12 at 13:37
  • @VonC thanks, but no luck in gexport. Maybe it's because it is answer for Mac – lulalala Feb 20 '12 at 13:46
  • @LazyBadger: good point (and +1 on your answer). – VonC Feb 20 '12 at 13:50
1

In assumption, that base VCS is still Mercurial and tool - TortoiseHG

  1. You have to have ready Git-repo (empty, pushable from local)
  2. If you have added and working (i.e configured properly - can pull|push with Github) hg-git, you have to add Git-URL into (local) repo hgrc ([paths] section)
  3. add OpenSSH keys to Github, verify key-based authorisation in THG (pageant)
    • AFAIK, only git+ssh://git@github.com/user/repo.git URL works for github from hg-git
  4. After it you'll have two remote linked repo, for both you'll be able to push/pull from Synchronize tab

Addons

Relevant parts from mercurial.ini, git and github related

[ui]
...
ssh = "...\TortoisePlink.exe"
...
[auth]
github.com.prefix = github.com
github.com.username = lazybadger

Can say nothing about last section, just recall nothing for "when" and "why"

Lazy Badger
  • 94,711
  • 9
  • 78
  • 110
  • I created the OpenSSH key using git-bash but can't load it into pageant. I think pageant only loads putty private keys? – lulalala Feb 20 '12 at 13:51
  • @lulalala - yes, you have to create putty-keypair with Puttygen or import OpenSSH key (?!) into Puttygen and save as putty – Lazy Badger Feb 20 '12 at 13:58
  • Cool now I have the keys set up, tried to push it in Synchronize: It gave me the error message `creating and sending data ... [command returned code 255 Mon Feb 20 22:04:23 2012]` – lulalala Feb 20 '12 at 14:10
  • Do you have pageant with keys running? Check **all** settings according to this check-list [TortoiseHg as a github client on Windows](http://jamesmckay.net/2010/06/tortoisehg-as-a-github-client-on-windows/): I done all step-by-step and got all functioning without errors – Lazy Badger Feb 20 '12 at 14:17
  • yes pageant is running, if it is not running it will give a 'pubkey' message. I'll check the doc now. – lulalala Feb 20 '12 at 14:21