Skip to content

Github Steps

Isaac edited this page Jan 24, 2019 · 3 revisions

This page is intended to explain the GitHub model we are using as well as provide go through its steps. It is meant to be a reference as you work on tasks. I will specifically reference how to do things in the bash terminal. TortoiseGit is a helpful downloadable tool but is not necessary. It is intuitive enough that you should be able to find the appropriate options in it, but I will go through steps for it as well for important parts.

This reference will NOT explain how GitHub works (there are many tutorials out there). I recommend going here to get familiar with bash terminal commands and the GitHub in general.

This page assumes:

First point early on: Commit frequently; if you ever wonder if you are committing too often, you are not. It is much easier to go back and recover code and versions if you have committed them. It is far better to have too many commits than too few.

Here is a general workflow that you would follow when given a new task:

  1. Update local code
  2. Create a feature branch
  3. Work and commit on that feature branch
  4. Get the feature branch into a finished, stable state
  5. Create a pull request

1: Always try to make your code up-to-date with the remote repository before you make changes. This is much less of an issue since we will all be working on separate branches, but it will still make the process much easier when merging Pull Requests (PRs).

To make sure you are up-to-date, checkout to the 'dev' branch (git checkout dev). Or checkout to whatever branch you are going to be branching off of (will almost always be 'dev'). Then pull from the remote repo to update your local repo (git pull origin dev).

You can pull in TortoiseGit:

  • Right-click in the folder
  • Select 'Git Sync'
  • Select 'Pull'

If you get an error make sure that at the top of the window you have chosen a 'Remote Branch' (should always match the 'Local Branch').


2: A feature branch should be something larger than a minor change. It is NOT bound to a single file being added or changed. There can be as many changes as necessary in order to implement that feature.

To create a feature branch:

  • Right-click in the folder
  • Hover over 'TortoiseGit'
  • Select 'Create Branch' (you could alternatively select 'Switch/Checkout' and check the option to 'Create New Branch')
  • Give the branch a name - please have the text 'feature' somewhere in the name
  • Under 'Base On' the option selected should almost always be 'HEAD (dev)' *If not, selected 'Branch' and change to be 'dev'
  • Check the option to 'Switch to new branch' (unless you do not want to switch, but you almost always will want to do this)
  • Select 'OK'

What you have done is created a new branch under 'dev' and switched to it.

To do this using the bash terminal you would enter: git checkout -b [new branch name] dev You use this same command to switch branches in the bash terminal, but the -b creates a new one.


3: From here on out you should stay on your feature branch as you make changes. Your feature branch should always remain ahead of the 'dev' branch since you are making changes.

As you work, regularly commit by:

  • Right-click in the folder
  • Select 'Git Commit -> "[name of branch]"'
  • You MUST write a message that explains briefly the changes that you made
  • Make sure all the files you changed are checked (if you created a new file you will need to check them)
  • Select 'Commit' at the bottom

Once you commit in TortoiseGit you should see a new window that lets you 'Push'. You may do so or wait and do it later.

To do the steps above in the terminal:

git add .
git commit -m "<put the commit message here (required)>"

Keep in mind that all commits are local, and are not pushed to the remote repo. To push:

  • Right-click in the folder
  • Select 'Git Sync'
  • Select 'Push'

If you get an error make sure that at the top of the window you have chosen a 'Remote Branch' (should always match the 'Local Branch'). ***If you push to either 'dev' or 'master' you will ALWAYS get an error, they are protected and can only be changed through PRs that have been peer-reviewed

In bash you would simply do: git push origin [name of branch]

It is up to you to push after every commit or to wait and do it after several. The only thing to point out is that you should push before closing your computer, so all changes up to when you were last working are saved.


4: Continue to commit and push until the feature is completed.


5: Once the feature is done, you create a Pull Request (PR) to merge them into the 'dev' branch.