Skip to content

Adding code to the repository

lbewlay edited this page Nov 4, 2016 · 1 revision

How to add code to the repo:

We are working on different branches:

  • master contains the code that is delivered. We should only merge back to master when there is a new release once we have finalised a milestone. This is the code that would go in the server.
  • develop is the parent branch of all the work we do. The rest of the branches branch out from this one and once finished are merged back to it.
  • feature/describingNameOfWhatYoureDoing is the names of the branches we should be working on individually. As mentioned, this feature branch should branch from develop.

These are the steps to follow to add code to the repo:

  1. Identify an issue you want to work on or create a new one for the development you want to do here.
  2. If you want to work on an issue, filter by the label needs_volunteer, choose an issue, remove the needs_volunteer label and assign it to yourself.
  3. If you identify an issue that is not recorded yet but you can't or don't want to work on it for whatever reason, create an issue with the needs_volunteer label for others to do. You can optionally add more labels that apply and assign it to a milestone you consider.
  4. Create a new branch out of the develop branch (so you first do git checkout develop, then do git checkout -b <name of new branch>.
  5. We are completing our work in feature branches, meaning we name them feature/whateverTheAimOfThisBranchIs.
  6. When finished, send your changes to the repository on Github. If you're not familiar with the steps involved, generally, they would go something like:
  7. Run git add nameOfFile in your command line terminal to stage your file for a commit. You can track everything that is staged via git status
  8. Commit your change to your local repo by running git commit -m [A commit goes here]. It is a good practice to include the Github issue number in your commit message as this ensures your commit is linked to the related issue in Github. So an example commit message would be git commit -m [Added a particular feature. #1] or so.
  9. Push your changes to Github by running git push origin feature/whateverTheAimOfThisBranchIs
  10. For more Git commands, check out this cheatsheet and more comprehensive git documentation.
  11. After you've pushed your branch to the remote Github repository, go to the project home page on Github and request a pull request against the develop branch. A pull request creates a new Github issue, so you can label it with needs_volunteer or assign it to someone directly.
  12. The person assigned looks through the code, makes comments, the author changes things if needed, and when ready, the reviewer merges your changes with develop and deletes the feature branch. See all PRs here.

We meet face to face every week, so if there is a possibility of conflict between two branches, the best would be to solve the conflicts on the weekly meeting, or otherwise via Slack/Skype with the author of the conflicting changes.

You can have a look at a graph of the current branches here: https://github.com/namibmap/IPPR/network

Also installing something like SourceTree, GitUp, or similar could help if you prefer using a GUI instead of commands.