Episode 11 of 12

Collaborating on GitHub

Learn how to collaborate with others using branches, pull requests, and code reviews.

GitHub's collaboration features make it easy for teams to work together on code projects.

The Collaboration Workflow

  1. Clone the repository
  2. Create a new branch for your changes
  3. Make commits on your branch
  4. Push your branch to GitHub
  5. Create a Pull Request (PR)
  6. Team reviews and merges the PR

Push a Branch to GitHub

# Create and switch to a feature branch
git switch -c feature/add-about-page

# Make changes and commit
git add .
git commit -m "Add about page"

# Push the branch to GitHub
git push origin feature/add-about-page

Creating a Pull Request

  1. Go to your repository on GitHub
  2. Click "Compare & pull request" (appears after pushing a branch)
  3. Write a description of your changes
  4. Select reviewers
  5. Click "Create pull request"

Code Review

Reviewers can:

  • Comment on specific lines of code
  • Approve the changes
  • Request changes if something needs fixing

Merging a Pull Request

Once approved, click "Merge pull request" on GitHub. Options include:

  • Create a merge commit — preserves full history
  • Squash and merge — combines all commits into one
  • Rebase and merge — applies commits on top of main

Staying Up to Date

# Pull latest changes from main
git switch main
git pull origin main

# Update your feature branch
git switch feature/my-feature
git merge main