Skip to main content


Project description


This tiny app does the dirty work of setting up a git repo inside an existing
hg repo so that you can work in git and push to remote hg repositories. If you
don't want to do this, it's because you don't understand how amazing git really

gitifyhg has been tested on Python 3.3. It might work on other interpreters.

* `source <>`_
* `pypi package <>`_
* `Dusty Phillips <>`_

gitifyhg explicitly depends on:

* ` <>`_
* `sh <>`_

These packages will be installed automatically by `easy_install`,
`pip`, or ` install`.

gitifyhg also expects the following to be installed on your os:

* `Mercurial <>`_
* `git <>`_
* `hg-git <>`_


gitifyhg is a properly designed Python package. You can get it from
`pypi <>`_ using either ::

pip install gitifyhg

or ::

easy_install gitifyhg

gitifyhg works in a `virtualenv `>`_, but you're
probably just as well off to install it at the system level.

You can also install manually by ::

git clone
python install

If you want to hack on it, use `` develop`` instead. In this case, you
probably **are** better off using ``virtualenv``


In addition to installing the hg-git dependency (I expect you have hg and
git installed already), you'll want to perform these steps before running

* Tell your ``~/.hgignore`` to ignore ``.git``. I suggest doing this in the
global ignore so sensitive mercurial users don't get too tetchy about the
fact that you think it's good to rewrite history. It would be possible to
make ``gitifyhg`` automatically add .git to the repo's .hgignore, but I have
tried to keep gitifyhg from requiring major changes to the repo.

* Clone an hg repo if you don't have one you want to work in.

* Add ``syntax: glob`` to the top of your ``.hgignore`` file and change
patterns to glob format. ``gitifyhg`` will link your .hgignore to your
``.gitignore``, and git prefers the glob syntax. If you choose not to do this,
you may have to unlink the gitignore

Now you can run ``gitifyhg`` in any hg directory and a local git repo is
created. You can use the ``git hgpull`` and ``git hgpush`` commands to push
your changes into the remote hg repository.

These commands are rather dangerous. They basically try to sync up the hg
default and git master branches. When you run ``git hgpull`` changes are pulled
into ``default`` from the upstream mercurial repository and git master is
hard reset to point at it. It's probably better if you don't have changes on
master that you didn't want obliterated.

``git hgpush`` does basically the opposite, it tries to sync up the hg default
branch with whatever commits have been pushed onto master, and then pushes it
to the remote repository.

A good workflow is to:

* Never commit to master. Create a new branch in git.
* When you are ready to merge that branch, first ``git hgpull`` to sync master
with the upstream mercurial repository.
* Rebase your working branch onto master. If you don't know about
``git rebase -i``, learn.
* Merge your working branch into master and delete the working branch. If you
don't delete it, hg-git will create a new bookmark for that git branch. That
won't hurt anything, but if you have git branches that have changes on them
that are not merged into master, those changes will also be pulled into
mercurial. This is probably not good because you probably don't want those
commits pushed upstream as an unnamed branch.
* ``git hpush`` to push your changes upstream.
* `hgview <>`_ is a terrific extension
for viewing hg history. It even shows your hggit branch location.
I recommend it over the git browsers because your colleagues are probably
using hg branches.
* If you need to track other hg branches, bookmark it and track it using
(I haven't tested this much)::
hg bookmark hg/branchname -r branchname
git branch --track branchname hg/branchname

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for gitifyhg, version 0.2
Filename, size File type Python version Upload date Hashes
Filename, size gitifyhg-0.2.tar.gz (2.7 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page