Getting Started – GitHub


Overview

This is a quick and easy tutorial to get up and running quickly with GitHub as your online repository.  What will be covered is how to get up and running using GitHub and some of the concepts that exist when you use it.  What I’ll be going through are as follows:

  1. GitHub Concepts
    • Collaborator
    • Organization
  2. Registering a GitHub Collaborator Account
  3. Registering a GitHub Organization Account
  4. Linking a Collaborator Account to an Organization Account
  5. Generating & Registering SSH Keys
  6. Creating a Repository
  7. Git Setup
  8. Connecting to a Repository
  9. Useful Git Links
  10. GitHub Help

GitHub Concepts

Collaborator

A collaborator in GitHub is the same as a user with the added benefit of having his own public account.  In other words a Collaborator has the ability to set up his own Repositories with their own Wiki sites per Repository.  This is quite a nice feature seeing that I can be linked to my Organization for those things that I do on their stuff, but I can also have my own source for articles I write or open source projects that I own.  The other really big thing that can be taken into consideration is that as a Collaborator you can join any current open source project and do some development for them.

Organization

An Organization is exactly what it says.  It’s a grouping of Projects and the Collaborators that work on the Organization’s projects.  GitHub allows you to manage teams, projects and repositories within the Organization, making it easier for the members of the Owners team to manage permissions.  So, if you take the hierarchy in a GitHub Organization then you would have something like this:

In the image above you’ll see that each Collaborator can still have his own Repository, while also having access to the Organization’s repositories.  In GitHub the members of the Owner Team has access to all Repositories as well as everything else, while Collaborators belonging to other teams will only have access to Repositories inside the Team.

Registering a GitHub Account

Go to the GitHub home page and select the “Pricing and Signup” option at the top of the page.  Once the page has loaded you can select the type of account you would like and then follow the process that follows.  In my case I selected the “Free Account” option seeing that I want to register an Organization in the next section of this short Tutorial.  Once selected, just follow the easy steps to completion and that should create an account for you to use as is and to create Repositories on.

Registering a GitHub Organization Account

Now that you have an Account with GitHub you might choose to create an Organization.  So, once logged into your Account, you should select the “Account Settings” option at the top.  Once the page has loaded you can select the “Organizations” tab, which will take you to the “Your Organizations” page where you can now select to “Create New Organization” where you can now choose your plan and follow the steps.

Linking a GitHub Account to an Organization Account

Now that you’ve created an Organization, you can add Collaborators.  So, if you go to your Organization’s GitHub home page, usually at:  https://github.com/organizations/YourOrganizationName, you should select to go to the “Teams” tab.  Once there you can now create a team by selecting the “New Team” button which will take you to a page where you can setup a new team, add Members (Collaborators) to the team and add Repositories.  You can also manage the types of permissions that the team can grant.

Generating & Registering SSH Keys

I will only be covering the generation of SSH Keys on an Ubuntu environment seeing that I don’t do this kind of development on my Windows environment.  So, to start you should go into your Ubuntu environment and open a “Terminal Window”.  Once this is open you can enter the following command which should take you to the folder where your SSH Keys should live:

cd ~/.ssh

Once there you can run the following command, replacing the username@email.com part with your own email address.

ssh-keygen -t rsa -C “username@email.com”

When it asks you for the file name you would like to use you should enter “id_rsa”.  I usually leave the passphrase section empty.  Once this has been completed you should now have two file named:  “id_rsa” and “id_rsa.pub” in your “.ssh” folder.  If you open the file ending with “.pub” you’ll see your public key.  You should copy this seeing you’ll be using this key when you register a new key on your Account in GitHub.

To add this key to your GitHub Account you should go back to your Account Settings page in GitHub.  Once there you should see an option for SSH Public Keys where GitHub will show you an RSA fingerprint and give you the option of adding another public key.  When you select that you should type in any “Title” and paste your generated Public Key into the “Key” box and select Add key.  Your Ubuntu machine should now be able to validate itself against your use account in GitHub.  To test this you can type the following command into your Terminal window in Ubuntu:

ssh git@github.com

This should come up with a message stating: “The authenticity of host ‘github.com (207.97.227.239)’ can’t be established.”  Accept the “Are you sure you want to continue connecting (yes/no)?” question that comes up by stating “yes”.  If you get the message –

”Warning: Permanently added ‘github.com,207.97.227.239’ (RSA) to the list of known hosts”

– you know that it has worked and that your machine can now authenticate itself against the GitHub servers.  You should only ever see this message once.

Creating a Repository

This is a very simple process.  Once you’ve logged into your account, you should go to the Organization’s dashboard.  Once the page has finished loading you will see a “New Repository” button on the right hand side of the page.

If you click on the button you can simply follow the process to finish creating the Repository.  A thing to note on this page is that you should select the relevant team this Repository belongs to.

You can change this at a later stage, but for now you can select the relevant team, which will then automatically allow that team to work on the “Project”.  Once your Repository has been created you should follow the steps in the next section that covers setting up your development environment to start working against this new Repository.

Git Setup

Now that you’ve created your Repository on GitHub and you’ve added your SSH Key to your Account, you’re ready to connect to your Repository from your Ubuntu machine and hopefully start coding.  So, to do this you’ll need to do a few things first.  Open a Terminal Window and type in the following command to download and install Git:

sudo apt-get install git

Once you’ve downloaded and installed Git, you should configure it to use the same User Name and email address that you registered your GitHub account with.  To do this you should run the following command to configure your User Name:

git config –global user.name “YOURUSERNAME”

To configure your email address you should run the following command:

git config –global user.email “YOUREMAILADDRESS”

This should conclude the install and configuration of your Git environment.

Connecting to a Repository

This is where it becomes a little bit more interesting.  To connect to a Repository in GitHub you’ll now have to go to the folder that you’ll be using as your development folder.  In my case I’m using “~/projects”.  Once there you should create a folder for this specific Repository which will be “Hello-World” in this scenario.  You can do this by running the following command from your Terminal Window:

mkdir Hello-World

Once your “Hello-World” folder has been created you should go into it and run the following command from your Terminal:

git init

This will initialize a local Git Repository for you.  Once done you should see a hidden folder called “.git” in your folder when you run the “ls –a” command.  Now you can create your first file by running the following command:

touch README

You should add this file to your local Repository by running the command:

git add README

Once done you should commit this “add” operation to your local Repository by running:

git commit –m ‘first commit’

Now that you’ve created a local Repository and committed your first file to it, you will want to push this up to your remote GitHub Repository.  To do this, you need to link your local Git Repository to your remote GitHub Repository.  To do this you will to run the following command:

git remote add origin git@github.com:YOURORGANIZATIONNAME/Hello-World.git

Now that you’ve linked your local Repository you can push by simply running the following command:

git push origin master

That’s it to get you up and running quickly.  For more information you can go to the sites listed below.

Useful Git Links

Cheat Sheet

This should cover most of what you need to do to work with Git.

http://help.github.com/git-cheat-sheets/

Git Reference Site

http://gitref.org/

Ignoring files

http://help.github.com/git-ignore/

Working with remotes

http://help.github.com/remotes/

GitHub Help

For further help on using GitHub I would strongly suggest you go to the GitHub help section for further assistance.  They have a lot of information there that should help you through most of the things you need to do.

  1. Andrea de la Huerta
    April 30, 2011 at 10:50

    Great article! Thx.

  2. kama
    June 30, 2012 at 16:43

    Useful, thx!

  3. April 10, 2013 at 03:45

    Link exchange is nothing else except it is only placing
    the other person’s website link on your page at appropriate place and other person will also do same in support of you.

  4. April 19, 2013 at 14:53

    Hi, of course this paragraph is genuinely nice and I have learned lot of things from it about blogging.
    thanks.

  5. Federico Lerner
    May 6, 2013 at 13:53

    Heya i am for the first time here. I found this board and I
    to find It truly helpful & it helped me out a lot. I hope to present one
    thing back and aid others like you aided me.

  6. May 27, 2013 at 16:48

    Hi there, all is going fine here and ofcourse every one is sharing facts, that’s actually excellent, keep up writing.

  7. June 1, 2013 at 10:43

    My brother recommended I might like this web site.
    He was entirely right. This post actually made my day.
    You cann’t imagine just how much time I had spent for this info! Thanks!

  1. No trackbacks yet.

Leave a comment