Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I've Vim plugin project on GoogleCode using Mercurial, but users wants to have it on github to ease use it as git subrepo (to keep their ~/.vim/ on github with all plugins inside).

Personally I prefer googlecode and hg over github and git, so I don't like to move my project to github, and prefer to implement sort of automatic git mirror for my hg repo. I've read these: Hg-Git mercurial plugin, Synchronizing a git mirror with hg-git and Create a Git Mirror and looks like with some extra headache this may work by using two commands in place of one:

hg push
hg push githubmirror

But, thing is, you know, most of us will forget to run second hg push from time to time. So, is it possible to automate this in some way (using hooks etc.)?

Another question - is there better way to make such mirrors? Maybe GoogleCode already provide git access to their hg repos? Or maybe it's possible to create git clone for hg repo and keep it in sync with original hg repo automatically by 3rd-party, without even notifying hg repo owner?

share|improve this question
create a script with both, save it and run it when you need to sync? –  Journeyman Geek Jan 28 '12 at 12:30
I've a lot of repos, and having to run custom script for some of them in no way better than having to run second hg push: it's change my workflow and thus will result in errors. –  Powerman Jan 28 '12 at 12:40
add comment

1 Answer

up vote 0 down vote accepted

You could do something like a post-commit hook. Have a look at http://www.selenic.com/mercurial/hgrc.5.html


Commands or Python functions that get automatically executed by various actions such as starting or finishing a commit. Multiple hooks can be run for the same action by appending a suffix to the action. Overriding a site-wide hook can be done by changing its value or setting it to an empty string. Hooks can be prioritized by adding a prefix of priority to the hook name on a new line and setting the priority. The default priority is 0 if not specified.

share|improve this answer
Using post-commit is bad idea becaise commit!=push. Using post-push also bad idea because 'post-push=hg push git' result in endless loop. But looks like 'outgoing' hook works ok. –  Powerman May 10 '12 at 17:47
@Powerman You can write a more complex hook which checks for the remote target, see hgbook.red-bean.com/read/…, section Where changes are going—remote repository URLs. –  schlamar Sep 4 '13 at 10:35
@schlamar What's wrong with 'outgoing' hook? Why I should need more complex hooks to solve this issue? –  Powerman Sep 4 '13 at 23:34
add comment

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.