Git, GitHub and an open source .NET project – Part 2

I have used the open source enterprise search platform Solr for a number of years now and on a recent project have been using the open source SolrNet .NET client library. The SolrNet library lacked a feature I required when used with the bundled Service Locator implementation. A number of people had been asking for the same feature so I decided to jump in and implement it.

This is part 2 of my journey into learning Git, using GitHub and contributing to an open source project.

What is GitHub ?

GitHub_LogoGitHub is the popular web-based hosting service for projects that use the Git revision control system. It has a large number of project management, code hosting and community based features.

Sign up for GitHub

GitHub offers a free account for open source projects. This account has an unlimited number of public repositories and public collaborators. There are also plans that cater for private repositories and collaborators.

Git_Part2_GitHubSignup

The source code for the SolrNet project is hosted on GitHub so I signed up for the free plan and created myself an account on GitHub.

Git_Part2_GitHubKeys

Once you have updated the Public Profile and Email Addresses sections of your account you will notice that you need to associate an SSH public key with your GitHub account.

Generate an SSH key

Fire up the PuTTY Key Generator executable puttygen.exe found in the PuTTY install folder.

Git_Part2_KeyGen1

Select the SSH-2 RSA radio button and ensure that the number of bits is set to 1024. Click the Generate button to generate the public/private key pair.

Git_Part2_KeyGen2

Cryptography calls for unpredictable random numbers. A simple way to obtain this randomness is to generate it from the user. The PuTTY Key Generator uses random mouse movements to generate randomness.

Git_Part2_KeyGen3

Give the generated key a comment and provide a passphrase. The passphrase provides an extra layer of security for your key. This is not my actual key but even if it was – all that is visible here is my public key which is meant for public distribution anyway …

Git_Part2_KeyGen4

Create a .ssh folder in your home folder. I created a C:\Users\paul\.ssh folder. Save your public key into this folder by clicking on the Save public key button.

Git_Part2_KeyGen5

Save the private key into your .ssh folder by clicking on the Save private key button.

Git_Part2_KeyGen6

You should now have a public/private SSH key pair for GitHub. My public key is github_rsa and my private key is github_rsa.ppk. Never let anyone have access to your private key !

Add public key to GitHub

Now we are ready to add our newly generated public SSH key to GitHub. Highlight the text in the Public key text box and copy it to the clipboard (CTRL-C).

 Git_Part2_AddKey1

If you have already closed the PuTTY Key Generator I’ll show you how to load the key back up. Fire up the PuTTY Key Generator executable again and click on the Load button.

Git_Part2_AddKey2

Select your GitHub private key file and click on the Open button.

Git_Part2_AddKey3

You’ll be required to provide your passphrase to load the private key.

 Git_Part2_AddKey1

Now highlight the text in the public key text box and copy it to the clipboard (CTRL-C).

Git_Part2_GitHubKeys

Go back to the SSH Public Key section in your GitHub account. Click on the Add another public key link.

Git_Part2_AddKey4

Paste (CTRL-V) the public key from your clipboard into the Key text box. Provide a Title for your key and click on the Add key button.

Git_Part2_AddKey5

GitHub is now set up with your SSH public key.

Next is forking the SolrNet project …

Git, GitHub and an open source .NET project – Part 1

I have used the open source enterprise search platform Solr for a number of years now and on a recent project have been using the open source SolrNet .NET client library. The SolrNet library lacked a feature I required when used with the bundled Service Locator implementation. A number of people had been asking for the same feature so I decided to jump in and implement it.

This is part 1 of my journey into learning Git, using GitHub and contributing to an open source project.

What is Git ?

imageGit is a free and open source, distributed version control system initially designed and developed by Linus Torvalds of Linux fame. Even though there are fundamental differences from a revision control system such as Subversion, there are numerous books and documentation available to help you.

The major difference with Subversion is that every Git working directory is a full-fledged repository with complete history and full revision tracking capabilities, not dependent on network access or a central server. This takes some time to get used to but once the light comes on it is pretty cool.

Install PuTTY

If you want to use GitHub you’ll need an SSH key. Even though Git comes with an SSH client, I highly recommended that you install PuTTY on Windows. This is a free Telnet/SSH client that has a number of utilities that make dealing with SSH keys and passphrases more pleasant.

I downloaded and installed the PuTTY 0.60 Windows Installer.image4

Make sure that you associate .PPK (PuTTY Private Key) files with Pageant (SSH authentication agent) and PuTTYgen (SSH key generation utility).

Install Git

To install Git on Windows you need to download Git for Windows and install it. I downloaded and installed the full installer for official Git 1.7.3.1.

image11

I was only interested in using the Git Bash shell via the Windows Explorer context menu and so selected the Git Bash Here option. Since I was installing TortoiseGit for GUI based Git interactions I did not want my context menu cluttered with the Git GUI Here option.

image13

I selected the Use Git Bash only option here since I wanted my Git environment to work smoothly and remain contained. I was also only ever going to use command line Git from the Git Bash shell.

image14

Since I have PuTTY and TortoiseSVN already installed the Git installer has picked up the various Plink.exe executables. Plink is a command line interface to the PuTTY libraries that tools such as Git or TortoiseSVN/TortoiseGit use to provide SSH capabilities.

I selected the Use (Tortoise)Plink option and made sure that the file path pointed to the Plink executable in my PuTTY install folder. Now Git will use PuTTY to manage its SSH requirements.

image15

Git can translate line endings between Windows and Unix style line endings. I selected the Checkout as-is, commit as-is option as this would not perform any conversions. I figured that if I was working on a Windows project it should have Windows line endings.

image

Confirm that Git for Windows has been successfully installed by firing up the Git Bash shell. I fired mine up in my projects folder.

Install TortoiseGit

TortoiseGit provides an extension to Windows Explorer that works with a Git repository. Some people feel more comfortable using graphical tools. I prefer to have both since I can use whichever one helps me get a specific task done faster or easier.

I downloaded and installed the Tortoise Git 1.5.8.0 Windows installer.

image20

Like Git, TortoiseGit also can be made to use the PuTTY Plink executable.

image21

I selected all the features and completed the installation. That was easy !

Git enabled !

I now had Git installed and was equipped with both the command line Git Bash shell and GUI based TortoiseGit options.

Next is setting up GitHub …

Git, GitHub and an open source .NET project – Introduction

I have used the open source enterprise search platform Solr for a number of years now and on a recent project have been using the open source SolrNet .NET client library. The SolrNet library lacked a feature I required when used with the bundled Service Locator implementation. A number of people had been asking for the same feature so I decided to jump in and implement it.

This is my journey into learning Git, using GitHub and contributing to an open source project. I highly recommend the experience – you learn a great deal from reading and contributing to code that is so highly visible.

I have split my journey into the following 5 parts:

Updating multiple iPhones with a single iOS 4.2 download

After a number of years of roughly 200MB upgrades for my iPhone 3G and then iPhone 4 I was shocked when the latest iOS 4.2 update weighed in at just over 600MB. Added to the gut punch was the fact that I had to upgrade 2 iPhones now – yes, my wife has joined the cult.

What is iTunes actually downloading ?

iTunes makes it really easy to upgrade your iPhone but I wanted to be able to download the update once and use it to upgrade both phones.

01 - New version available

iTunes hides all the details from you – so how was I going to get at the iOS 4.2 firmware update file (.ipsw) ?

Use the proxy luke !

An HTTP proxy is a tool every developer should know how to use. I use Charles on Mac OS X. Fire up Charles to force all the HTTP traffic through a proxy and then click on the Update button in iTunes to start the download.

02 - iTunes

The other major factor in downloading this update only once is clearly visible in the status column. My ADSL router was on its way out and I just couldn’t get decent download speeds at the time. Thank goodness those days of darkness are behind me now – I’m very happy with my new LinkSys Dual-Band Wireless-N ADSL2+ Modem Gigabit Router. But I digress …

03 - Charles HTTP Proxy

The iOS 4.2 firmware update file (.ipsw) that iTunes was downloading is clearly visible in Charles:

We now have the complete URL for the file and can download it outside of iTunes. Stop the iTunes download as its purpose had now been served.

Download

I use curl when downloading large files and since it is bundled in Mac OS X there is no extra download or installation required.

04 - Curl download file

The "-C –" switch combination tells curl to automatically calculate where to resume the transfer. This ensures that if the connection drops or is reset you can resume the download where you left off.

The "-O" switch tells curl to save the download to a local file with the same name as the remote file.

Install

Fire up iTunes and hold down the option key while clicking on the Update button.

 01 - New version available

05 - Option update

The file selection dialog will open. Select the iOS 4.2 firmware update file (.ipsw) you have just downloaded.

06 - Select file

All the next steps will be familiar since they are all part of the standard steps for iOS updates.

07 - Update

Confirm that your iPhone has been updated.

08 - Updated

Now repeat the Install steps for each of your iPhones that you want to update.