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

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?


1 answer

1 accepted

0 votes
Answer accepted

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 ( 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.



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?

I just found this, but I've never tried it before:

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 :)

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

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
Community showcase
Published Mar 14, 2019 in Bitbucket Pipelines

Building a Bitbucket Pipe as a casual coder :  #!/bin/bash source "$(dirname "$0")/" enable_debug extra_args="" if [[ "${DEBUG}" == "true" ]]; then extra_args="--verbose" fi # mandatory variables R...

314 views 0 12
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you