Skip to content

How to contribute code using Github

thijs edited this page Feb 16, 2017 · 60 revisions

This page describes how you can contribute code to the Hydrogen project using Github The page is mainly aimed at Linux users, but should contain enough info for Mac and Windows users

1) Goto github.com

2) Clone the Hydrogen repo

3) Clone the code from your Github repo to your PC

  • On your github repo page you will see a 'Clone or download' button, click it and you will see the 'Clone with SSH' box :

clone URL

  • Copy the URL using the clipboard icon next to it
  • On your pc create a directory that will hold your local repo
  • Open a terminal and cd to the directory you just created
  • Now enter 'git clone' and paste the URL you copied above. This should look like this : 'git clone [email protected]:yourname/hydrogen.git' :
    $ git clone [email protected]:yourname/hydrogen.git
    Cloning into 'hydrogen'...
    remote: Counting objects: 28218, done.
    remote: Compressing objects: 100% (16/16), done.
    remote: Total 28218 (delta 8), reused 0 (delta 0), pack-reused 28202
    Receiving objects: 100% (28218/28218), 15.39 MiB | 2.94 MiB/s, done.
    Resolving deltas: 100% (19189/19189), done.
  • Cd to the new Hydrogen subdir that was created and check the git status with 'git status' :
    me@mypc:~/Git/Hydrogen/yourname$ cd hydrogen
    me@mypc:~/Git/Hydrogen/yourname/hydrogen$ git status
    # On branch master
    nothing to commit (working directory clean)
  • Now tell Git your email and name :
    me@mypc:~/Git/Hydrogen/yourname/hydrogen$git config --global user.email "[email protected]"
    me@mypc:~/Git/Hydrogen/yourname/hydrogen$git config --global user.name "Thijs Van Severen"

... and you are all set !

4) Build Hydrogen (see this wiki page)

5) Fix a bug or create your own new Hydrogen feature

6) Build Hydrogen and test your new feature

7) Commit your changes

  • Use the 'git status' command to see what files have been modified :
    me@mypc:~/Git/Hydrogen/yourname/hydrogen$ git status
    # On branch master
    # Your branch is behind 'origin/master' by 1 commits, and can be fast-forwarded.
    #
    # Changes not staged for commit:
    #   (use "git add <file>..." to update what will be committed)
    #   (use "git checkout -- <file>..." to discard changes in working directory)
    #
    #	modified:   src/gui/src/SongEditor/SongEditorPanelTagWidget_UI.ui
    #
    no changes added to commit (use "git add" and/or "git commit -a")
  • First you have to add these files to your local repo using 'git add' :
   me@mypc:~/Git/Hydrogen/yourname/hydrogen$ git add src/gui/src/SongEditor/SongEditorPanelTagWidget_UI.ui
  • Lets check the git status again using 'git status' :
   me@mypc:~/Git/Hydrogen/yourname/hydrogen$ git status
   # On branch master
   # Changes to be committed:
   #   (use "git reset HEAD <file>..." to unstage)
   #
   #	modified:   src/gui/src/SongEditor/SongEditorPanelTagWidget_UI.ui
   #

As you can see the file has been added to the repo but this addition still needs to be committed with the 'git commit -m "my comment"' command :

    me@mypc:~/Git/Hydrogen/yourname/hydrogen$ git commit -m "set the tag column header to stretch over the whole window"
    [master 625945a] set the tag column header to stretch over the whole window
     Committer: yourname <yourname@yourpc.(none)>
    Your name and email address were configured automatically based
    on your username and hostname. Please check that they are accurate.
    You can suppress this message by setting them explicitly:

        git config --global user.name "Your Name"
        git config --global user.email [email protected]

    After doing this, you may fix the identity used for this commit with:

        git commit --amend --reset-author

8) Push the changes from your local repo (on your PC) to your remote github repo (on the Github server) using 'git push'

    me@mypc:~/Git/Hydrogen/yourname/hydrogen$ git push
    Counting objects: 13, done.
    Delta compression using up to 8 threads.
    Compressing objects: 100% (7/7), done.
    Writing objects: 100% (7/7), 713 bytes, done.
    Total 7 (delta 5), reused 0 (delta 0)
    To [email protected]:yourname/hydrogen.git
       71e9ed5..625945a  master -> master

9) Verify that your new commit is now available in your github repo

check your commit

10) Create a pull request

Your code has now been uploaded to your personal Github repo, but it has not been merged into the main Hydrogen repo yet. To do this you need to make a 'pull request'.

A pull request is basically asking the Hydrogen Github repo responsible to have a look at the code you created (or modified) and (if your work looks good) merge it into the Hydrogen repo.

At this point it is very likely that you will be asked for some more info, or to make some modifications to your code. Please don't be offended by this : this is the only way that we can guarantee a high quality application. We will always tell you why your code needs to be modified and help you with all your questions.

compare changes

  • Note that the 'base fork' (the original Hydrogen repo) and 'head fork' (your repo) are automatically filled in (but you can manually change this if needed)
  • Also note that github has already checked if the 2 branches can be merged
  • Now click the 'create pull request' button and enter some info about this pull request (more info = better)

open a pull request

  • Click the 'Create pull request' button and your pull request will be submitted to the maintainers of the main Hydrogen repo.

11) Check your pull request && wait

Your pull request will now be listed on the pull request pqge of the Hydrogen repo

pull request has been submitted

12) Pull request is accepted

Once your pull request is accepted your code will be merged in to the main Hydrogen repo and your pull request will be updated :

pull request merged

13) Goto step 5 ;-)

Clone this wiki locally