Saturday, March 11, 2017

Git: Sync a single local repository to both Github and Bitbucket

It turns out to be fairly simple to sync a single local git repository to both Github and Bitbucket. I use SourceTree for my single repository, which originally pointed solely to Bitbucket.  I did an Import of that repository into Github and now want all my commits using SourceTree to push to both remote repositories.

I just modified my local .git/config file to include another pushUrl.  No changes required in SourceTree, but when SourceTree does a push, both remotes will be updated.

Before:

[remote "origin"]
url = https://bitbucket.org/xyz/bitbucket.repository.name
fetch = +refs/heads/*:refs/remotes/origin/*
pushurl = https://bitbucket.org/xyz/bitbucket.repository.name

After:

[remote "origin"]
url = https://bitbucket.org/xyz/bitbucket.repository.name
fetch = +refs/heads/*:refs/remotes/origin/*
pushurl = https://bitbucket.org/xyz/bitbucket.repository.name
pushurl = https://github.com/xyz/github.repository.name

No comments:

Can't RDP? How to enable / disable virtual machine firewall for Azure VM

Oh no!  I accidentally blocked the RDP port on an Azure virtual machine which resulted in not being able to log into the VM anymore.  I did ...