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:

[paths]
default = ssh://hg@bitbucket.org/<bb_user>/<bb_project_name>
github = git+ssh://git@github.com:<gh_user>/<gh_project_name>.git

[ui]
username = <name_surname> <<your_email>>
verbose = True

[extensions]
hgext.bookmarks =
hggit =
 
[hooks]
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.

OR

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

Credits: http://morgangoose.com/blog/2010/09/29/github-and-bitbucket-hooks/

Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox