A beginner’s guide to git and GitHub

Octocat

The goal of this guide is to get you through your first code contribution to an open source project. The Parallel Architectures Library (PAL) will be used as the example.

(“git” is a distributed revision control system started by Linus Torvald in 2005. GitHub is a startup that offers Git repository hosting service.)


 Step #1: Set up a GitHub account

Free for all open development (private repository accounts cost money).

registration


Step #2: Navigate GitHub

For the most part GitHub is self explanatory, but you can see 3 of the most important buttons you will need below.

navigate


Step #3: Fork a repository

To start contributing to an existing repository (like PAL) you must first create your own personal copy. The easiest way is to log into your GitHub account, browse to an existing repository like (PAL), and to click the ‘fork’ button. See Step #2 if you can’t find the button


Step #4: Setup git on your local machine

Before stating to work on the code you your machine, you will need to install and setup git. If you are using Ubuntu, you can install git easily:

 $ sudo apt-get install git
 $ git config --global user.name "Your Name"
 $ git config --global user.email "youremail@domain.com"

Step #5: Clone your fork

Downloads the repository from GitHub to your local machine.  There is a copy paste button in GitHub for those of you with ‘fat fingers’ like me. See Step #2 above if you can’t find the button.  Substitute address with your fork of the repository.

ReferenceHow to clone

 $ git clone https://github.com/parallella/pal

Step #6: Adding files

If you are adding new files or folders, use the ‘git add’ command. If you are just editing existing files you can skip this step.

Reference: How to add files

 $ git add src/math/p_abs.c

Step #7: Commit your changes

Once you have completed some changes, commit them to your local repository (on your machine). Use “commit -s” to sign your contributions for good practice. many projects require signoff.

Reference: How to commit changes

 $ git commit -s src/math/p_abs.c

Step #8: Push changes to your own GitHub fork

Before you can contribute your local changes to the mainline repository you must first sync with your

Reference: How to push

 $ git push

Step #9: Submit Pull Request

Now you are ready to submit a pull request to the upstream repository that you forked from (PAL in this case). The easiest way to manage this is through the GitHub web page. See Step #2 above if you can’t find the button on GitHub.


Step #10: Communicate

Once you have submitted your pull request, be ready for comments submitted in response to your PR.

2 Comments

  • Adam says:

    Thanks Andreas, thats very helpful.

  • Elana says:

    Skype has opened its web-dependent consumer beta towards the world, right after starting
    it generally in the Usa and U.K. earlier this 30 days. Skype for Web also now supports Chromebook and Linux for immediate text messaging interaction (no video and voice however,
    those call for a connect-in installment).

    The expansion from the beta contributes help for
    an extended list of different languages
    to help reinforce that worldwide functionality

Leave a Reply