Overview: This blog post covers how you can use “GitHub for Windows” with BitBucket to give you free online source control storage for your projects. Phil Haack recently blogged on how you can use GitHub for Windows with git repositories hosted elsewhere, I thought I would provide a step by step guide on how to do this with Bitbucket.
Many of us work on little side projects, it is what geeks do. But I am still surprised at the number of people that give me a blank look when I ask them what source control they are using on their personal projects. “We use TFS at work”, is the usual response, “but I don’t do anything with my own code. I just zip it up at now and then”.
Lets change this. It couldn’t be easier to get started!
Git is a great tool for doing source control locally, it supports change sets so that you can see how your code evolved over time. Unfortunately it can be difficult to get started with Git due to the number of command line tools and new concepts that need to be learnt. This is where GitHub for Windows comes in. It lets you easily create Git source code repositories and check your change sets in, via a nice visual interface.
To compliment this, there are 2 main websites that allow you to synchronise your local Git repositories with online cloud storage, meaning that your source code is safe from your computer blowing up, and also allows you to work across multiple PCs (or team mates).
- https://GitHub.com/ – Free for public repositories, but you pay for private repositories
- https://Bitbucket.org/ – Free unlimited private repositories, but you pay to add more than 3 team members
Personally, I use GitHub for anything that I share with other people (code samples, tutorials, etc.) and I use Bitbucket for my own personal projects. I previously blogged about my use of Github https://davidburela.wordpress.com/2012/04/17/developer-blog-banter-3-responsecommunity-coding/
Connecting Bitbucket with GitHub for Windows
It is really easy to connect and start backing up your projects to Bitbucket.
- Install GitHub for windows http://windows.github.com/
- Sign up for a free account at https://bitbucket.org/
- From Bitbucket, select Repositories –> Create new repository.
- Create a new Git repository
- Once created, you will be taken to the repository’s home page. Copy the repository url
- From the start menu, open the Git Shell and paste in the git command that was copied in the previous step. This will create a new folder, create a new git repository inside that folder, and link that repository with the online repository on Bitbucket.org. This means you’ll be able to keep the 2 in sync easily.
- Open GitHub for Windows.
- To let GitHub for Windows know about the repository, simply drag the folder from windows explorer onto the application window. This will allow you to commit change sets and synchronise with the online repository.
- Start adding files to the folder (or create a new Visual Studio project inside that folder), then commit change sets periodically.
- Once you have committed a number of change sets to your local git source repository, push the change sets up to your Bitbucket account by clicking the publish button.
- If you browse to your repositories home page, you will see all of the change sets synchronised.
- To retrieve the source code from another machine, simply repeat the first few steps to install GitHub for Windows, open a Git shell to run the initial command and drag the folder into the Github for windows app to start committing and publishing change sets.
With free tools and online storage, there are NO reasons for you to not use some form of source control to keep your projects safe. Start using it on one of your projects now and save your code from a lost hard drive!
If you want to start learning advanced git concepts, then here are some resources to help you get started
- The simple guide to using Git http://rogerdudler.github.com/git-guide/
- A guided tour of Git http://gitimmersion.com/
- Scott Hanselman’s guide to contributing to a GitHub repository http://www.hanselman.com/blog/GetInvolvedInOpenSourceTodayHowToContributeAPatchToAGitHubHostedOpenSourceProjectLikeCode52