Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Now that SourceTree supports both Hg and Git, is it possible to pull from one and push to the other?

Tim Long June 29, 2013

My specific situation is that I have created a fork of an open-source project, which uses Mercurial (Hg). My fork contains private code so I don't want to just make a public clone (it is hosted on CodePlex). So I have cloned the project and pushed it to my Stash server, which is based on Git.

SourceTree for Windows can now access both repositories (hooray!)

What I'd really like to do is periodically pull the changes from the original Hg repository into my Git repository and push them up to my Stash server, so I keep up to date with development on the base product.

In Subversion, I think they would call this a 'Vendor Branch'.

Right now, I have to maintain two separate working copies and manually port the changes between then. This means that I lose all the history from the parent project and the merge operation is tedious and error prone. It would be much nicer if I could just pull changes from the Hg repository directly into a branch in my Git repository. I've seen various things online that are supposed to be able to do this, but I haven't been able to get any of them to work (the documentation is mostly for Linux and we are using Windows).

So is this even theoretically possible in SourceTree?

Thanks.

1 answer

1 accepted

0 votes
Answer accepted
stevestreeting
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 30, 2013

It's not supported to have a single working copy which has both a hg and git repo inside it at once right now, and actually because you have to maintain 2 separate sets of commits that's not really that useful anyway. You could use Hg-Git (http://hg-git.github.io/) to push/pull a remote Git repo with a local Hg repository, but because Git doesn't have 'full' extensions there isn't anything (AFAIK) to do the reverse, ie keep a local Git repo and collaborate with a Hg remote - you can only do a once-only conversion using fast-export.

Alternatively I guess you could create a local folder as a remote Git repo and work mostly in that, then use Hg-Git to pull commits from that into the Hg repo, which could then be pushed upstream. It still requires 2 local folders, but at least you're pulling actual commits rather than replicating the file changes and re-committing in the other system.

HTH

Steve

Tim Long June 30, 2013

Steve, thanks for your input. My specific situation is that I really want to work entirely in Git. I only want to pull from the vendor's remote Hg, I never want to push back to it (equivalent to a Vendor Branch in Subversion). So really what I need is something that keeps a Git branch synchronized with an Hg remote branch. Is there anything like that?

If everyone used the same DVCS then life would be simple, but the real world isn't like that. I would have thought this was a fairly common use-case?

stevestreeting
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 30, 2013

I just found this, but I've never tried it before: https://github.com/rfk/git-remote-hg

Tim Long July 6, 2013

Thanks again Steve. That seems like a perfect solution but I haven't been able to get it to work. Most of the documentation is Linux-biased but even after setting up an Ubuntu VM I wasn't able to get it to work. I'll keep trying because if I can get it going, it would perfectly fit my needs. It would be nice if SourceTree could have this concept built in though :)

stevestreeting
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 7, 2013

Well, we kinda support both hg and git so you don't have to do this ;)

Tim Long July 8, 2013

Well, until very recently, SourceTree for Windows didn't support Hg. Now that it does, all that's changed is that I can now clone my Hg repository in the GUI instead of using Hg command line. This doesn't address my use case of keeping a 'vendor branch'in my Git repository (in Stash) in sync with an external readonly Hg repository. As I said, I can periodically merge the vendor branch manually, but its a manual process, tedious, error prone and I don't get all the history from the remote repo. What I really want to be able to do is to pull a branch from Hg directly into my Git repository. Git-remote-hg is probably the closest potential solution so far, but I've been unable to get it to work at all (I'm getting messages about Git not being compiled with python support).

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events