20
Aug
11

work with git, push to mercurial repo


I would like to give credit for most of this information to Chris Adams’s article. Thank you Chris!

  1. Install git
  2. Install Mercurial
  3. Get hg-git from hg-git page
  4. NOTE: If you install TortoiseHG with Mercurial, you get dulwich for free. I don’t know if this applies for a regular Mercurial install as well ( I always get the package that contains TortoiseHG )
  5. Open the .hgrc file, and add this to it:

    
    [extensions]
    hggit=/path/to/extracted-hg-git/hggit
    bookmarks=
    [git]
    intree=1
    
    [bookmarks]
    track.current=True
    
  6. hg clone hgrepo
  7. Create a bookmark from the first revision of Mercurial’s default branch:
    
    hg book hg/default -r default
    
  8. Export it to git:
    hg gexport
  9. Create the git master branch:
    git branch --track master hg/default
  10. The git repository is a bare one, so, you should clone your repo elsewhere to work on it:
    git clone repo new_repo_location
  11. Work on new_repo_location, do commits, and then do a push so the changes get back to the Mercurial repo
  12. Go back to the original Mercurial repo, and import the git changes:
    hg gimport
  13. Push them via Mercurial

Advertisements

3 Responses to “work with git, push to mercurial repo”


  1. 1 Jorued
    August 23, 2011 at 11:10

    Hi,

    This looks pretty good, but I’ve just got a question. If I’ve set everything up like you explained, and someone else pushes a change to the Mercurial repository, how do I pull this change into my git repo?

    Thanks for sharing this

    Cheers

  2. 3 Ryan
    October 25, 2011 at 23:21

    I tried this however when I try to pull change fromt he mercurial repo to the git repo it just says it is up-to-date, anyone else special I need to do?


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


Blog Stats

  • 228,119 hits

%d bloggers like this: