Both Bitbucket and Github are excellent choices to store your code; this isn’t a post about which one is best. Instead, the goal of this post is to document the steps I followed to move one of my projects from Bitbucket to Github, and what I did to wire up Github to Azure to automate the deployments of said project.
When I first started working in this project, I needed to use a cloud-based repository as a backup and to have it accessible from any computer at any time. I’ve been using Bitbucket’s free private repositories for a while now, and most of my projects are still there.
“Bitbucket is more than just Git code management. Bitbucket gives teams one place to plan projects, collaborate on code, test, and deploy.”
The text below is the description from bitbucket’s website. It is, in fact, a complete solution for code management. Just like Github, it does offer an easy-to-use interface and workflows to make building and deployment of your code a breeze.
However, one of Bitbucket’s advantages until recently was the unlimited free private repositories. For individuals with many projects like myself, paying for an external repository for each software experiment I create it’s just not feasible. Bitbucket understood this from the start, and this is the reason many developers, and probably small companies use their free private repositories.
“GitHub is a development platform inspired by the way you work. From open source to business, you can host and review code, manage projects, and build software alongside 31 million developers.”
The paragraph above is from Github’s website. While Github became very popular among the open source community, it just wasn’t a feasible solution for individuals or small companies looking to use private repositories and without resources to pay for them, at least not until now. You see, Microsoft acquired Github on October 2018 and this, perhaps, allowed them to expand their offerings and offer free private repositories. Regardless of the reason, it was a great move by Github, and I’m sure some people have switched to Github from other places now that they are offering free private repositories.
How do you move your code to a different remote repository?
Moving your code from one cloud repository to another is in fact, very simple if you are only moving a self-contained application like the one I moved. Technically, you don’t move your existing repository; you change the settings in your local repository to point to a new remote repository. For example, my project’s source lives in my laptop, under a folder labeled c:\repos\iai and since this folder is already set up as a Git repository, all I had to do is execute the following Git command:
git remote set-URL origin https://github.com/ricardodsanchez/iai.git
The command above allowed me to change the URL from one remote Git repository to another one, instead of removing and re-adding.
IF my code weren’t set up with a remote Git repository yet, I would have needed to use the following command to add the new remote Git repository:
git remote add origin https://github.com/ricardodsanchez/iai.git git push -u origin master
That’s all, after you execute the command above, your local repository will be connected to the new Github remote repository.
Setting continuous deployment in Azure with new Github repository
Fortunately, this was also very easy, and Azure enables you to set up your application with continuous deployment by connecting to one of the following source control options:
- Azure Repos
- Local Git
Since I had already connected my web application with Bitbucket in Azure’s deployment center, all I had to do was disconnect it from Bitbucket, and then connect it to Github. To do this, you have to log in to the Azure portal, click on the App Services you want to change, and then go to Deployment Center under Deployment. Once you are there, you disconnect any existing repositories and then go through the steps to connect a new one.
After re-connecting my application to a new remote repository (Github), continuous deployment was again active and set up to automatically run every time I merge any code to the project’s Master branch in Github.
Below is a screen shot of the log after finishing the move and merging new changes to my project:
If you try browsing to the Github URL shown in the screenshot above you’ll get a 404 (Page Not Found) error, this is because this is a private repository.
The application for which code I moved from Bitbucket to Github is called Interns and Internships, and while it isn’t 100% complete yet, you can visit it here: