Week 2: Git Branches and Collaboration

2025-07-07

Welcome to Week 2!

Theme: Git Branching & Collaboration

This week, you’ll:

  • Understand how teams collaborate using Git

  • Use branches to safely make changes

  • Learn how to merge code and resolve conflicts

Filenames (and variable names)

Why Use Branches?

Git branches let you:

  1. Experiment safely without breaking the main code

  2. Collaborate efficiently by working in parallel with your teammates

  3. Organise your project into logical feature units

Example Workflow:

Git Branch Basics

Common branch commands:

# List all branches
git branch  

# Create + switch
git checkout -b new-feature   

# Go back to main
git switch main        

# Delete a merge branch
git branch -d old-feature

Collaboration with GitHub

To work with others, you’ll:

  1. Clone a repo

  2. Make changes in a new branch

  3. Push your branch to GitHub

  4. Open a pull request

    Pull Requests = Propose changes + get feedback + merge cleanly

Working as a Team

Key habits for collaboration:

  • Pull the latest changes often:
    git pull origin main

  • Communicate: use comments, issues

  • Keep commits small and meaningful

  • Don’t fear conflicts — learn to resolve them

    Good Git habits = less stress for your team

Let’s Dive Into The Live Session