Skip to content

Git Workflow

Fabien SHAN edited this page Dec 8, 2017 · 2 revisions

Abstract

Git is the Version Control System (VCS) that we are using to maintain & distribute our code. It can be quite daunting to start with, so below is a (hopefully) comprehensive workflow to follow when creating features or fixing bugs.

Branches

Whenever you add something to the codebase, be it a new feature, a bug fix, a typo correction, or anything else, you should do so on a new branch.

You can create a branch by typing the below command into your terminal/command prompt window

$  git checkout -b branch-name-here

This will create the branch, and check you out onto it, so you are immediately ready to start working on it.

Making changes on your branch

Naturally you will be making changes to the codebase while working on your branch. These changes will eventually need to be made available to other developers on your team, so that they can review and eventually merge it into the main branches.

Committing & Pushing

You can add changes that you have made and tested to the recorded history of your branch by running the below series of commands (assuming that you are in the root of the project directory tree)

    # Show what's changed
$   git status

    # Stage all changes, ready to be committed (you can also add individual files by running git add your-filename-here
$   git add .

    # Commit all staged changes, with a message written in the quotes
$   git commit -m "Made some changes"
    
    # If you have not yet pushed your branch to the remote...
$   git push --set-upstream origin your-branch-name

    # If you have already pushed from this branch before...
$   git push

Creating a pull request

Once you've made your changes and are ready to have your code reviewed, you need to create a pull request for your branch. You can do this by going to your branch on the Github site, and click the Pull Request button at the top of the list of files.

You should add at least Olly as a reviewer, and ideally the other member of the team as well, so we all have an understanding of how things work.

Rebasing a branch

If a branch has been merged while you're still working on yours, you'll need to rebase your branch before creating a pull request, to bring it back up to speed with the main (develop) branch.

You can do this by running the below command from your branch

$   git rebase develop

This will merge the changes to the develop branch into your branch, and reduce the chance of merge conflicts when your branch gets merged into develop.

It is possible, and indeed quite likely given the team size, that you will get file conflicts when you attempt to rebase - if this happens, talk to X140hu4 and work through it together.

Taken from Olly

Clone this wiki locally