Sync BitBucket and GitHub

From Darii Denis's Personal Wiki
Jump to: navigation, search

Here I'll explain how I automaticaly sync your github repo on each hg push:

First install all the dependencies:

$ pip install mercurial
$ pip install hg-git
$ pip install -U dulwich # upgrade it to avoid git remote error: unpack index-pack abnormal exit

Add in the repo's .hg/hgrc add something like this:

default = ssh://<bb_user>/<bb_project_name>
github = git+ssh://<gh_user>/<gh_project_name>.git

username = <name_surname> <<your_email>>
verbose = True

hgext.bookmarks =
hggit =
post-push = if [ $HG_ARGS = "push" ]; then hg push github; fi

<bb_user> with your bitbucket username

<bb_project_name> with your bitbucket project name

<gh_user> with your github username

<gh_project_name> with your github project name

<name_surname> with your name and surname

<your_email> with your email

now make a bookmark of master for default, so a ref gets created:

hg bookmark -r default master -f

and then at every hg push you'll update also the github repo.


hg push git+ssh://<gh_user>/<gh_project_name>.git to push only to github repo.


Personal tools