Private Git repositories

Home / Private Git repositories

I really like Github. However, I don’t want to have to pay for the service just to utilize private repositories. If my only option were to pay for a code hosting service, I would probably just host my own git repository.

There are other options for free private git hosting services, though.


One such service is Bitbucket. I played around with it a few weeks ago and moved my SVN repositories to it. This was a relatively painless process using “git svn” to perform the conversion. To keep things simple, I generally moved the entire truck of my SVN repositories into a single git repository. Otherwise, if you want to follow the typical git pattern of a single repository per project, it’s a lot of manual work. This can be a pretty tedious task when moving decades worth of SVN source code.

If you’re moving from another git host, though, I found that the process is direct and allows you to move all of the branches and history very easily.

After creating a new, private repository in Bitbucker, you only need to add it to the lists of remotes for your existing repository. My basic process of moving from my original remote to Bitbucket looks like this:

git clone <some repo>
cd <repo folder>
for remote in `git branch -r | grep -v /HEAD`; do git checkout --track $remote ; done
git remote add bitbucket <bitbucket remote https url>
git push -u bitbucket --all

The key is the 3rd line in bash script that iterates over all of the remote branches and checks them out. Once that occurs, we have the full history of the remote repository in our local clone of the repository. And, when we push all to the new remote, which I simply called ‘bitbucket,’ all of the history and branches go with it. After the push is complete, we can confirm through the Bitbucket web interface that all of our source is now in the private Bitbucket repository. All in all, considering that it’s a free service, I’m pleased. Having moved code to the private Bitbucket repo, new options are opened up – like continuous integration/deployment to your favorite git supported cloud hosting like Azure.

Leave a Reply