Getting Started with Git on GitHub
After the awesome F# for Scientists Book Club meeting the other night, I wanted to set up a code repository for everyone to share their code.
After some discussion on the Google Groups list, we decided to use Git instead of Subversion for the source control. Sure, why not? Might as well try out something new. We found GitHub.com which offers free hosting for public projects.
Installing the Git Client
I hunted around for a TortoiseSVN-esque Windows client for git, but there isn’t one (yet?). Ah well, back to the command line with Cygwin. I usually have Cygwin installed, but my installation on this machine is broken for whatever reason. Thankfully I stumbled onto msysgit, an all-in-one installer.
I ran the installer, using all of the default options:
Git uses SSH under the covers to connect to the remote git repository, so we need to spend a second setting up our public/private key pairs.
Double-clicking on the “Git Bash” shortcut on my desktop brings me up to a MINGW32 command prompt. I need to generate new SSH keys, so I did:
$ ssh-keygen.exe
This generated a few files:
~/.ssh/id_rsa = Private key
~/.ssh/id_rsa.pub = Public key
You’ll need to cat the id_rsa.pub file and copy/paste that public key (starting with the “ssh-rsa” line) into your GitHub account next.
Creating a GitHub account
Just sign up for a free Github account (pretty self-explanatory).
You’ll need to provide the SSH public key (not the private key!) to github so that you’ll have permission to commit. You can enter the key on the first screen (it’s optional), or add one once you’ve created the account.
Using Git
I just followed the directions on the fsharpbooksamples project page.
$ cd /d/OpenSource/
$ mkdir fsharpbooksamples
$ cd fsharpbooksamples/
$ git init
Here I created and edited a README.txt file
$ git add README.txt
$ git config –global user.email matt.valerio@gmail.com
$ git commit -m ‘Initial commit’
$ git remote add origin git@github.com:mattvalerio/fsharpbooksamples.git
$ git push origin master
And, that’s about it. Note that on the last push command, it will fail if you don’t have your SSH keys set up correctly. It will complain with an error message that says “Permission denied (publickey)”. If you set up a passphrase while generating your SSH keys, you’ll need to enter that here.
Hope that helps!
You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.
Leave a Reply