← Back to Hub

GitHub Workflow Tutorial

Learn the complete Git/GitHub workflow for team collaboration

1
2
3
4
5
6
7
Setup Branch Changes Commit Push PR Review

Step 1: Setup & Clone

First, let's make sure you have Git installed and clone the repository.

Check Git Installation

Terminal git --version

You should see something like git version 2.x.x

Clone the Repository

Your instructor will provide the repository URL. Clone it to your machine:

Terminal git clone https://github.com/YOUR-ORG/w19d2-qlearning.git

Navigate to the Project

Terminal cd w19d2-qlearning
Tip
Open the folder in your code editor (VS Code, etc.) to see the project files.

Check Your Remotes

Terminal git remote -v

You should see origin pointing to the GitHub repository.

Quick Check

What does git clone do?

Step 2: Create a Feature Branch

Branches let you work on features without affecting the main code. Each team member creates their own feature branch.

Branch Structure

main
team-a
feature/learning-rate ← You create this!

First, Switch to Your Team Branch

Make sure you're on your team's branch first:

Terminal git checkout team-a # Replace with your team name

Create Your Feature Branch

Name your branch based on your improvement area:

Terminal git checkout -b feature/learning-rate # Your improvement

Branch naming conventions:

Verify Your Branch

Terminal git branch

The asterisk (*) shows your current branch.

Practice: Build the Command

git -b
Warning
Never work directly on main or your team branch. Always create a feature branch!

Step 3: Make Your Changes

Now you'll edit w19d2_starter.py to implement your improvement.

Open the File

In your code editor, open w19d2_starter.py. Look for sections marked with:

Python # ========== MODIFY HERE ==========

Example: Learning Rate Strategy

w19d2_starter.py def get_learning_rate(self, state=None): # ========== MODIFY HERE: LEARNING RATE STRATEGY ========== # Default: Fixed learning rate # BEFORE: return self.learning_rate # AFTER: Decay learning rate over time return self.learning_rate * (0.999 ** self.total_updates)

Test Your Changes

Run the script to train and see live graphs:

Terminal python w19d2_starter.py

The script auto-manages a virtual environment and shows a matplotlib training graph.

Best Practice
Make small, incremental changes. Test after each change to see the effect.

Check What Changed

Terminal git status

This shows which files have been modified.

Terminal git diff w19d2_starter.py

This shows the exact lines that changed.

Step 4: Stage and Commit

A commit is a snapshot of your changes with a message describing what you did.

Stage Your Changes

Tell Git which files to include in the commit:

Terminal git add w19d2_starter.py

Verify Staged Files

Terminal git status

You should see your file listed under "Changes to be committed".

Create the Commit

Terminal git commit -m "Add adaptive learning rate decay"

Good Commit Messages

Tip
Start with a verb (Add, Fix, Update, Implement, Remove). Keep it under 50 characters.

Quick Check

What's the difference between git add and git commit?

Step 5: Push to GitHub

Now let's upload your branch to GitHub so others can see your work.

Push Your Branch

Terminal git push -u origin feature/learning-rate

The -u flag sets up tracking, so future pushes just need git push.

Verify on GitHub

Go to your repository on GitHub. You should see a message about your recently pushed branch:

🔀 feature/learning-rate had recent pushes less than a minute ago
What Just Happened?
Your code is now on GitHub! Others can see your branch, but it's not merged yet.

Multiple Commits

If you make more changes later, you can:

Terminal git add js/qlearning.js git commit -m "Improve learning rate decay formula" git push

Step 6: Create a Pull Request

A Pull Request (PR) asks to merge your branch into the team branch. It's where code review happens.

Create the PR on GitHub

  1. Click the "Compare & pull request" button (or go to Pull Requests → New)
  2. Set the base branch to your team branch (e.g., team-a)
  3. Set the compare branch to your feature branch
  4. Fill in the PR template

PR Title & Description

PR Title Add adaptive learning rate decay strategy
PR Description Template ## Summary Implemented exponential learning rate decay to improve convergence. ## Changes Made - Modified `getLearningRate()` in qlearning.js - Learning rate now decays by 0.999 per update ## Evaluation Results - Baseline: 180 ± 45 - After change: 235 ± 52 - Improvement: +30% ## Testing - [x] Trained with seed=42, 500 episodes - [x] Ran 100-episode evaluation - [x] Exported Q-table as evidence
Always Include
  • What you changed and why
  • Your evaluation results (before/after)
  • How to test your changes

Request Reviewers

Add your teammates as reviewers. They'll check your code before it can be merged.

Step 7: Code Review & Merge

Code review ensures quality and shares knowledge across the team.

As a Reviewer

Review Actions

✓ Approve
Code looks good, ready to merge
💬 Comment
Questions or suggestions, no decision
✗ Request Changes
Issues that must be fixed before merge

Responding to Feedback

If reviewers request changes:

  1. Make the requested changes locally
  2. Commit and push (same branch)
  3. Reply to comments explaining what you changed
  4. Request re-review

Merging

Once approved, click the "Merge pull request" button. Your code is now part of the team branch!

After Merging
Update your local repository:
git checkout team-a git pull

Completion Checklist