This course will become read-only in the near future. Tell us at if that is a problem.

Setting up Git and using Github

Clone, commit, push, pull, rinse and repeat!


For this course, GitHub is used as a central repository for exercise submissions. Each course participant will create an account on GitHub, fork (i.e., copy) the course repository, modify the skeleton files to complete assignments, and push the completed work back up to GitHub for all to see and review.

Installing Git

git is a distributed version control system. Version control systems are an important toolkit in a developer's arsenal: they allow developers to track changes to their code over time and operate well in a team. Developers usually commit small changes as they complete features, creating revisions that are archived and never lost.

git is the most popular version control system used with Ruby at this time.

git does not have the gentlest learning curve, but the basic functions are pretty straightforward and well documented.

Reading Assignment: Learn more about git by reading Pro Git - Git Basics.

Task: Sign up for a free account on GitHub.

Reading Assignment: After you've learned about git at a high level, setup git on your local machine by following the instructions on GitHub for your platform. Follow the entire guide, including setting up SSH keys.

Alternatives to installing GIt:

Its great that technology makes life eaiser for us, but its better to know how the internals of a system works.  For those less adventurous here are some other ways of interacting with git and github.



Forking the Course Repository

Reading Assignment: Read the GitHub guide to forking a repository.

Task: Fork the coursework repository. Specifically, follow along with this screencast.


Task Discussion

  • trycatchblock said:

    leads to a 404. What happened here?

    on 18 mei 2013 12:57

    sad_tigger said:

    on 18 mei 2013 14:15 in reply to trycatchblock

    Andre Dublin said:

    sorry about that I updated the link

    on 19 mei 2013 22:45 in reply to trycatchblock
  • __hsams__ said:

    Installed on Fedora 18, from the repos, because I'm lazy.
    on 25 januari 2013 18:12
  • Jure said:

    Installed Windows gitHub

    on 29 oktober 2012 08:13
  • David O'Dowd said:

    I'm hoping I have done this all correctly.

    on 29 september 2012 22:05

    Andre Dublin said:

    Right on track David

    on 29 september 2012 22:33 in reply to David O'Dowd

    David O'Dowd said:

    Thanks Andre. It might be worth adding steps about what does. Should people be using it or should they be learning by using the commands.

    on 30 september 2012 07:21 in reply to Andre Dublin

    Andre Dublin said:

    I'd like the course to introduce people to the command line, since ruby and rails both use it heavily.  Also being comfortable in the command line gives people confidence in other areas of software development.

    Thanks, I'll add it to the course materials.

    on 30 september 2012 20:15 in reply to David O'Dowd
  • RobRoy said:

    I found dublinan/coursework repository empty. I don't get it. 

    on 10 september 2012 18:38

    Andre Dublin said:

    What do you need assistance with?

    on 11 september 2012 07:13 in reply to RobRoy

    Georgiy Slobodenyuk said:

    It should only have a README file. It is meant to be copied and modified. 

    on 11 september 2012 12:47 in reply to RobRoy

    RobRoy said:

    OK. I thought I find in the repository partly prepared exercises. Now I understand, I need to write them and then put into repository.

    on 11 september 2012 12:58 in reply to Georgiy Slobodenyuk
  • Shubham said:

    on 19 augustus 2012 01:21

    narendhar said:


    on 19 augustus 2012 02:56 in reply to Shubham

    Andre Dublin said:


    on 19 augustus 2012 20:40 in reply to Shubham
  • narendhar said:

    Created my git account

    on 17 augustus 2012 09:40

    Andre Dublin said:

    Looks good, if your using your own repo for the course that is fine smiley

    on 17 augustus 2012 09:42 in reply to narendhar

    narendhar said:


        I am a novice in this field.What is use of these repo in ruby?

    on 17 augustus 2012 10:16 in reply to Andre Dublin

    Andre Dublin said:

    I'm just having you all as students understand some basic git commands with this challenge, and understand basic parts of github.

    The use of github repos will allow me to read over your work and provide help where needed.  If that answers your question.

    on 17 augustus 2012 10:23 in reply to narendhar
  • Frank Murphy said:

    Ok, getting some time fianlly.

    Git account setup.

    One error on:

    git remote add upstream git://

     git fetch upstream

    fatal: The remote end hung up unexpectedly

    on 1 april 2012 07:03

    Andre Dublin said:

    can you provide a link to your git account

    on 1 april 2012 09:42 in reply to Frank Murphy

    Frank Murphy said:


    on 1 april 2012 09:54 in reply to Andre Dublin

    Andre Dublin said:

    Ok, here is how you will copy your repo localy

    $ git clone


    You won't have to set up a remote because cloning, automatically creates it.  Then all you have to do is follow this workflow

    $ git add <fllename>


    $ git add .

    . is all files that have been changed/added to the repo

    $ git commit -m "your message here"
    $ git push origin master


    You won't have to worry about using upstream, upstream is used when say your working from two different machines, or you have collaboraters on a project and there are changes to the remote repo git fetch upstream will pull in those changes for you without merging.

    on 1 april 2012 11:16 in reply to Frank Murphy
  • Anoniem said:

    All steps went ok, git account is set up. I followed the github page tutorial. (mac lion) 

    on 12 maart 2012 00:52
  • Peter Hwang said:

    I'm having some problems cloning.  See below.  Any ideas on what I'm doing wrong?


    Peters-MacBook-Air:~ hwangpet$ git clone
    Cloning into 'coursework'...
    error: cannot run ssh: No such file or directory
    fatal: unable to fork

    on 11 maart 2012 13:35

    Rhodee said:

    The error seems to be telling you that github can't find your public keys:


    So try this:


    If this is the only identity you have (i.e. only one github account) you can simply follow  along. If you have something more involved we might need to talk about your ssh setup.


    Shoot a message when you have worked through those steps (you only have to do it once)...unless this happens again.


    on 11 maart 2012 14:14 in reply to Peter Hwang

    Peter Hwang said:

    Thanks.  Now I'm stuck on step 3.


    Peters-MacBook-Air:.ssh hwangpet$ ssh-keygen -t rsa -C ""
    -bash: ssh-keygen: command not found

    on 11 maart 2012 17:16 in reply to Rhodee

    Andre Dublin said:

    Did you run this command at your prompt?

    ssh-keygen -t rsa -C ""

    Just want to make sure your didn't put any extra words/characters in there


    Also it seems your running Lion OS X

    run echo $PATH in terminal and let me know the response.

    on 11 maart 2012 18:02 in reply to Peter Hwang

    Peter Hwang said:


    Thanks for reply.   See below:


    Peters-MacBook-Air:.ssh hwangpet$ ssh-keygen -t rsa -C ""
    -bash: ssh-keygen: command not found

    Peters-MacBook-Air:.ssh hwangpet$ echo $PATH

    on 11 maart 2012 18:11 in reply to Andre Dublin

    Andre Dublin said:

    I think that you may have to install Xcode to obtain developer tools such as ssh.  Or you can roll your own and install openssh. However I recommend install Xcode.

    on 11 maart 2012 19:35 in reply to Peter Hwang

    Peter Hwang said:

    Installed xcode - still get the same errors.  Any other ideas?

    on 11 maart 2012 20:41 in reply to Andre Dublin

    Rhodee said:

    Hi Peter,

    Did you install xCode 4? I am not a Mac user, but this thread seems to be relevant:


    Perhaps since xCode appears to install git it simply can't find the path you can tell it to like this post suggest:


    Keep plugging away man!

    on 11 maart 2012 21:14 in reply to Peter Hwang

    Anoniem said:

    Peter, check it: It may help with the ssh problem

    on 12 maart 2012 00:54 in reply to Peter Hwang

    Andre Dublin said:

    Hey Peter,

    Can you echo your $PATH again now that Xcode is installed?

    I'm hunting an answer for you.

    on 12 maart 2012 12:22 in reply to Peter Hwang

    Peter Hwang said:


    Here the result after running echo $PATH in terminal:

    wifi-dhcp-55-168:~ hwangpet$ echo $PATH


    Thanks again for all the help fellas!  I'm going to work with one of my developers today who already use github so hopefully they can point me in the right direction.

    on 12 maart 2012 12:32 in reply to Andre Dublin

    Andre Dublin said:

    It looks like your missing some necessary binarys in your PATH variable

    these basic path settings should be in your .bash_profile like so

    export PATH=/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:$PATH

    Not sure where your Xcode is, but your developers should understand the situation

    on 12 maart 2012 12:44 in reply to Peter Hwang

    Peter Hwang said:

    Andre - you were correct.  My .bash_profile was corrupted.  My echo $PATH looks normal now:

    wifi-dhcp-55-168:Users hwangpet$ echo $PATH

    Thanks alot everyone!


    on 12 maart 2012 14:29 in reply to Andre Dublin

    Andre Dublin said:


    on 12 maart 2012 14:50 in reply to Peter Hwang
  • Andre Dublin said:

    I think you might be right about requiring git before you install rvm, but i believe you usually use curl to install...

    on 9 maart 2012 22:25
  • Mark Finlay said:

    This one is a bit tricky with all the diferent steps between installing git, setting up the account and the ssh keys so that the installed Git on your machine can talk to your Github account.

    From what I can remember, to install RVM it also requires you to have Git installed on your machine for some reason. This might help poeple having trouble installing RVM.

    on 9 maart 2012 19:43

    Mark Finlay said:

    Hey guys,

    I'm glad Peter is up and running. I remember having allot of the same issues trying to the different bits a pieces put together myself. I see that Peter has in his bash_profile:


    I was wondering how does this actaully work? My understanding so far is that when you call a program to perform an action in the command line, for example "rails server", "mysql -u root" or "git init", the comand line looks for the named program in the directories mentioned in the bash_profile file. Am I right? Could someone clarify?

    Again, another aussumption is that, for programs to talk to each other on a host they need to know where each other exist on the hard disk. If I have a rails app that needs to resize an image, how does the rails app know where ImageMagick is? Do the diferent applications use the bash_profile as a directory to find each other?

    Also, How does the syntax of the bash_profile files or shell script work interms of tying libraries and applications together?

    Where does RubyGems and Bundler fit into this whole thing?

    Obviously this kind of stuff plays an important part in your development enviornment but it's plays a massive role in delievering code. Interms of depoying ruby applications to the web it's important to have a solid handle on how to setup Linux boxes. It would be great to get pointers to goood resourses on more learning for this kind of stuff.

    on 16 maart 2012 20:18 in reply to Mark Finlay

    Andre Dublin said:

    Hey Mark, excellent question!

    The string you see when you use echo $PATH in terminal is a result of a UNIX variable.  It tells terminal where to find the binarys necessary to execute programs the " : " is a delimiter that lets you specify multiple paths to where your binaries are located in the file system.

    How Ruby knows where to find stuff because when ruby is built for your particular machine, it has predefined directories to hold libraries.  Where these reside all depends on the machine you are using. So an Ubuntu OS Ruby location may be different from a Windows OS Ruby location, or when you install RVM the Ruby location is different and so on.

    If you run this command in terminal

    ruby -e 'puts $:'

    You will receive an output of the directories that Ruby is using.

    $: is a Ruby array variable of places to search for loaded files.

    As for Rubygems, it is a standardized packging and installation framework for Ruby libraries and apps.  Thus making it easier to install, upgrade, and locate Ruby packages.  Keeping lots of Ruby developers including myself sane.

    Rubygems handles all the dependencies, and version control of gems to install on your system.

    Bundler is sort of an extension for Rubygems in Ruby applications, using Gemfiles to install and locate gems necessary for your application.

    I hope this answers your question, here are some links below to help you further understand.

    The PATH Variable in UNIX



    on 16 maart 2012 22:37 in reply to Mark Finlay