Github workflow

Managing your source code is a very important facet of programming (old news :)... however using the best tool for the job is a bit more current of a discussion.

at undoLogic we use both Github and SVN depending on the project. And because we do use both services we can make both very different and efficient for the project. 

GITHUB: Whenever creating software you need to keep your master clean (which mitigate weird issues that creep up) and this requires us to create a branch for each feature we work on and then create a pull request to commit the work.

SVN: Ideal when you are working on a simple project (eg a website) you are not creating complex software and you need a easy download (checkout), modify, and upload (commit) = job done ! - Click here to view our SVN workflow FAQ

# 1 > Clean master

It is suggested that you enforce a clean master by limiting who is able to push into master
-> This ensures all staff push into a separate branch
-> You can specify specific members who can push to master
-> Reviewers will merge the branches into the master

1. First time Settings - Branches - Add (Subsequant times you can click 'edit')
2. Branch name pattern: 'master' (without the quotes)
3. CHECKBOX Restrict who can push to matching branches
4. OPTIONAL: Add names of specific users that are allowed to push directly to master
5. Click Save

# 2 > GITHUB: Start work - checkout MASTER

Before you start working you first want to checkout the MASTER branch from the source code

Using PHPstorm -> Checkout -> Github -> Dropdown to choose the project (after you are loggedin) -> set the local path where you want to store the source files


To check that you are working on MASTER
-> Bottom Right -> Github: Master

You can click and popup the window to manage
-> You will NOT be able to commit/push to master (unless you have reviewer access)

-> If a branch has already been created that you are to work on view in remote branches and click 'checkout as...'

-> If you are starting a new task you need to create a NEW branch
-> Click '+ New Branch'

# 4 > GITHUB: Branch Name

The name you will take MUST:
- include a unique task number from your project management
- Then add a hyphen and end with a brief description of what you are doing (This allows to quickly understand when viewing in the history) EG: 9999-Work_to_complete

CHECKOUT BRANCH: This means you will auto SWITCH into the branch and be able to start working on it (suggested)

Click OK

# 5 > GITHUB: Verify

While you are working on your code you can verify that you are in the correct branch at the bottom right side
-> Git: .......

You can click to view options
-> i.e. you can switch back to master or another branch you might have open 

# 6 > GITHUB: Commit

After you finish working on your task and are complete
-> Commit (top right green array)
-> Ensure the correct files are checked that you want to commit
-> Verify you are commiting to the correct branch
-> Add a message describing what you completed
-> Click commit (still more work to do)
-> click down arrow and commit+Push (work complete - ready for review)

# 7 > GITHUB: Push

After commit is complete it will ask you to PUSH your code to the server
-> This means NOW others can see your work that you did (before this point it was only available to you local to your computer)

You are able to see that you are pushing to the correct branch
-> click push


When you are satisfied with your work you want to let the reviewer know it is time to:
-> Merge your code into the master branch (which will include your changes on the LIVE software)

If you do not create a PR, your changes will never appear on the LIVE software

# 9 > PR - Create Pull Request

Description: Add a description of the feature that is to be merged into the master (and launch to LIVE public)

Show Diff: You can click this - then click 'files' to view which files were included in this feature

OK: Click ok to send the pull request

# 10 > PR - complete

The Pull Request is complete

The reviewer will now review your code and if no issues will merge your code into the master (and go LIVE public)

If there are any issues your Pull Request will be denied and you will work to update any issues that were found by the reviewed.

# 11 > REVIEWER - PR's

As the reviewer:
- When you login to GitHub click on 'Pull Requests' in the top menu
- Checkout the code on your local computer and view the changes (on this branch)

- If the changes are approved, click the down arrow to choose the merge type
- I suggest Squash / merge - meaning all the commits from this work is pushed into one commit
- Then click 'Squash / merge'

# 12 > Delete branch

After the work has been merged
- The reviewer is able to delete the branch ON THE SERVER - click delete

However: The local branch that the staff used to work on will remain until it is manually deleted
-> Ensure the staff manually deletes the local branch 
-> You will notice the 'remote' branch is already deleted (in the screenshot)