Skip to content

Development

Einar Valur Aðalsteinsson edited this page Jun 29, 2015 · 5 revisions

Before you start to write any code, make sure that you are on your own branch. This is not going to be a Git tutorial but I will give you the basic commands... google the rest.

New branch

Make sure that your master is up to date. In the module's root directory:

$ git checkout master && git pull origin master

Now that the master is up to date, create your branch. The simplest way to do that is to check out a branch that does not exist but apply the -b operator to have Git create it.

$ git checkout -b new-branch

Develop

Now you can do your coding. When ever you commit, please write a meaningful comment.

  1. Make it start with an uppercase letter.
  2. Make it in past tense: Added... Created... Modified...
  3. Try to be specific, think of the person that has to decipher you cryptic comment.

Once you are happy with what you have written or just want to save your code to a remote repo, it's time to push.

Push

Move you code to git's staging area and then push

$ git add .
$ git commit -m "Added fixes to failing unit-tests"
$ git push origin new-branch

Now go over to GitHub. You will see that you have requested a Pull Request. Confirm that you want to create it.

Here you have an opportunity (and you should take it) to write more detail description about your Pull Request. Don't be afraid to add some code-samples, drawing, pictures, what ever... to explain what this PR is all about.

Build

When ever you create a PR or commit code to an existing branch. GitHub will notify a build server. The build server in turn will notify GitHub about the status of the build. You will start in the orange, telling you that the build has started. Waiting to hear about ...

screen shot 2015-06-30 at 6 16 38 am

If you are lucky. At the end of the build, you will be in the green. This means that no errors were found in your code.

screen shot 2015-06-30 at 6 14 42 am

Some of us are not that lucky. We might end up in the red, at which case you have to click the Details link to find out what went wrong and fix it.

screen shot 2015-06-30 at 6 27 48 am

Rebase.

It's a good idea to regularly, but before a merge it's a must.

Make sure you have all your current branch's code committed. Got back to you master and pull.

$ git checkout master
$ git pull

Now got back to you branch. Here a little trick. To go back to the branch you were on before you changed, you can use the - operator

$ git checkout -

Now you master is up to date. What we want to do it to it to put brach in the state it was when you first branched off. Then we want to play all the master's commit on it. The we want you play all your commit on top of that. To do this, do:

$ git rebase master

Now you might get some unresolved merge issues. Go into to the files and manually correct these issues. Once done, add them, but don't commit

$ git add .

To continue with the rebase do:

$ git rebase --continue

Once that's all done, commit to GitHub. Since you have no changed history, you have to force the commit, for that you have the -f operator

$ git add .
$ git commit -m "Rebased to master"
$ git push -f origin new-branch

If now everything is up to date and you have had your code reviewed, you can merge with master.

Clone this wiki locally