Collaboration is at the heart of GitHub. Whether you're working with a team on a private project or contributing to open-source software, GitHub provides powerful tools to work together effectively. This lesson covers everything you need to know about collaborating on GitHub, from basic pull requests to advanced team dynamics.
By the end of this lesson, you will be able to:
Fork repositories and contribute to projects using industry-standard workflows
Create and manage pull requests that follow best practices
Conduct effective code reviews and provide constructive feedback
Collaborate with team members using GitHub's advanced features
Follow open-source contribution guidelines and etiquette
Manage team permissions and implement security best practices
Troubleshoot common collaboration issues
Before diving into the technical details, let's understand common collaboration scenarios you'll encounter:
You find a bug in a popular library your project depends on. You'll need to fork the repository, fix the bug, and submit a pull request.
Your team is building a new feature. Multiple developers need to work on different components simultaneously without conflicts.
As a senior developer, you need to review junior developers' code, provide feedback, and ensure quality standards.
A critical bug is found in production. You need to quickly collaborate to fix, review, and deploy the solution.
A fork is a personal copy of someone else's repository. It allows you to:
Experiment with changes without affecting the original
Propose changes to the original project
Use someone else's project as a starting point
Maintain your own version with custom modifications
Navigate to the repository you want to fork
Click the "Fork" button in the top-right
Choose where to fork (your account or organization)
Wait for the fork to complete
bash
git clone https://github.com/your-username/forked-repo.git
git remote add upstream https://github.com/original-owner/original-repo.git
git remote -v
bash
git fetch upstream
git checkout main
git merge upstream/main
git push origin main
Set up a GitHub Action to automatically sync your fork with the upstream repository:
yaml
name: Sync Fork
on:
schedule:
- cron: '0 0 * * *'
workflow_dispatch:
jobs:
sync:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Sync upstream changes
run: |
git remote add upstream https://github.com/original/repo.git
git fetch upstream
git checkout main
git merge upstream/main
git push origin main
A pull request (PR) is a way to propose changes to a repository. It:
Shows what changes you want to make
Allows discussion and review
Can be tested before merging
Creates a record of why changes were made
Make changes in a branch
bash
git checkout -b feature/my-feature
git add .
git commit -m "Add new feature"
git push origin feature/my-feature
Open PR on GitHub
Click "Pull requests" -> "New pull request"
Select base and compare branches
Add title and description
Assign reviewers and labels
Click "Create pull request"
Be clear and concise
Use conventional commits format:
feat:
New feature
fix:
Bug fix
docs:
Documentation
style:
Formatting
refactor:
Code restructuring
test:
Tests
chore:
Maintenance
markdown
## Description
Brief description of changes
## Type of Change
- [ ] Bug fix
- [ ] New feature
- [ ] Breaking change
- [ ] Documentation update
## Testing
- [ ] Tests pass locally
- [ ] Added new tests
## Checklist
- [ ] Code follows style guidelines
- [ ] Self-reviewed code
- [ ] Commented hard-to-understand areas
- [ ] Updated documentation
Create early for feedback
Mark as "Ready for review" when complete
Prevents accidental merging
bash
git add .
git commit -m "Address review feedback"
git push origin feature/my-feature
Can be closed without merging
Provide reason for closing
Can be reopened later
mermaid
graph LR
A[Create Branch] --> B[Make Changes]
B --> C[Push to GitHub]
C --> D[Open PR]
D --> E[Code Review]
E --> F{Approved?}
F -->|Yes| G[Merge]
F -->|No| H[Make Changes]
H --> C
Quality : Catch bugs and improve code
Knowledge Sharing : Learn from each other
Consistency : Maintain coding standards
Documentation : Discuss why decisions were made
Understand the Context
Read PR description
Check related issues
Understand the goal
Review the Code
Check for bugs
Verify logic
Ensure readability
Check style consistency
Test Changes
bash
git fetch origin pull/123/head:pr-123
git checkout pr-123
Provide Feedback
Be constructive
Explain why, not just what
Suggest improvements
Acknowledge good work
Click the + next to any line to comment
Drag to select multiple lines, then comment
suggestion
# Your suggested code here
Approve : Changes are good to merge
Request Changes : Must address before merging
Comment : General feedback, no approval
Focus on Important Issues First
Security vulnerabilities
Performance problems
Logic errors
Design issues
Use the Right Tone
markdown
❌ "This code is terrible"
✅ "Consider refactoring this for better readability"
❌ "Wrong approach"
✅ "What do you think about using Strategy pattern here?"
Provide Examples
markdown
Instead of: "This could be more efficient"
Try: "This could be more efficient. Consider using:
```python
# Instead of
result = []
for item in items:
if item.is_valid():
result.append(item)
# Use
result = [item for item in items if item.is_valid()]
``` "
Self-Review First : Check your own PR before requesting reviews
Keep PRs Small : Aim ``for < 400`` lines of code changes
Respond Professionally : Thank reviewers and explain your decisions
Don't Take It Personally : Reviews improve code, not judge you
CODE_BLOCK_12
Read : View and clone
Triage : Manage issues and PRs
Write : Push to repository
Maintain : Manage repository settings
Admin : Full access
Go to Settings -> Manage access
Click "Invite a collaborator"
Search by username or email
Select permission level
Group permissions by team
Nested teams for hierarchy
Team discussions
Code review assignments
Settings -> Branches -> Add rule:
Require pull request reviews
Dismiss stale reviews
Require review from CODEOWNERS
Require status checks
Require up-to-date branches
Require signed commits
Include administrators
Create .github/CODEOWNERS
:
CODE_BLOCK_13
CODE_BLOCK_14
CODE_BLOCK_15
Reference in commits: Fixes #123
Reference in PRs: Closes #123
Cross-reference: See #123
Common label categories:
Type : bug
, enhancement
, question
Priority : high
, medium
, low
Status : in-progress
, blocked
, ready
Area : frontend
, backend
, docs
Group issues and PRs
Track progress
Set due dates
Release planning
GitHub Projects for task management:
Kanban boards
Automated workflows
Custom fields
Different views
GitHub Explore
Trending repositories
Topics of interest
Good First Issues
Label: good first issue
Label: help wanted
Sites like goodfirstissues.com
Contributing Guidelines
Read CONTRIBUTING.md
Check issue templates
Understand code of conduct
Find an Issue
Check if someone's working on it
Ask to be assigned
Fork and Clone
CODE_BLOCK_16
Create Branch
CODE_BLOCK_17
Make Changes
Follow style guide
Add tests
Update documentation
Submit PR
Reference the issue
Describe changes
Be patient for review
Start small
Communicate early
Follow the project's conventions
Be respectful and patient
Learn from feedback
Don't take rejection personally
CODE_BLOCK_18
Choose the Right Project
Active community (recent commits)
Clear documentation
Welcoming to beginners
Has "good first issue" labels
Before You Start
Read ALL documentation
Set up development environment
Run existing tests
Join community chat/forum
Making Your Contribution
Start with documentation/typos
Fix simple bugs first
Add tests for your changes
Follow commit conventions
GitHub Discussions for:
Q&A
Ideas and feedback
Show and tell
Polls
General discussions
Markdown formatting
@mentions for notifications
Emoji reactions
Task lists in comments
References to issues/PRs
Managing notifications:
Watch/Unwatch repositories
Notification settings
Email vs web notifications
Notification filters
Live Share in VS Code
Codespaces for cloud development
GitHub Mobile for on-the-go
GitHub Actions for CI/CD
Bots for automation
Webhooks for integrations
GitHub Apps for extended functionality
Dependabot for dependency updates
Security advisories
Code scanning
Secret scanning
Over-communicate
Be clear and concise
Document decisions
Use appropriate channels
Write clean code
Add meaningful comments
Include tests
Update documentation
Small, focused PRs
Regular commits
Descriptive messages
Timely reviews
Be respectful
Give credit
Help newcomers
Say thank you
CODE_BLOCK_19
Problem : Git can't automatically merge changes
CODE_BLOCK_20
Solution :
CODE_BLOCK_21
Problem : Can't push to repository
CODE_BLOCK_22
Solution :
Check if you have write access
If contributing to open source, push to your fork
Ensure you're using correct credentials
Check SSH keys are configured correctly
Problem : GitHub won't let you merge PR
Common Causes & Solutions :
Failing tests : Fix the failing tests
Merge conflicts : Resolve conflicts first
Required reviews : Wait for approval
Out of date : Update branch with main
Protected branch : Check branch rules
Problem : Can't push files over 100MB
CODE_BLOCK_23
Solution :
CODE_BLOCK_24
Objective : Practice the complete PR workflow by contributing to a practice repository.
Fork the practice repository: github.com/example/practice-contributions
Clone your fork locally
Add upstream remote
Create a new branch: git checkout -b add-your-name
Add your name to CONTRIBUTORS.md
Create a file: profiles/your-username.md
with:
markdown
# Your Name
## About Me
Brief introduction
## Skills
- Skill 1
- Skill 2
## Projects
- Project 1
- Project 2
Commit changes with descriptive message
Push to your fork
Create PR with:
Clear title: "Add [Your Name] to contributors"
Description explaining changes
Reference any related issues
Request review from a peer
Respond to feedback
Make requested changes
Get PR approved and merged
Objective : Practice giving constructive code reviews.
Find a peer's PR in the practice repository
Review their changes:
Check for typos
Verify formatting consistency
Suggest improvements
Leave at least:
One positive comment
One suggestion
One question
GitHub CLI - Command-line interface for GitHub
Refined GitHub - Browser extension
Octotree - Code tree for GitHub
GitHub Desktop - GUI client
GitHub Learning Lab - Interactive courses
First Contributions - Practice contributing
Open Source Guides - Best practices
GitHub collaboration features enable teams to work together effectively. You've learned:
How to fork repositories and contribute to projects using industry-standard workflows
Creating and managing pull requests with professional descriptions
Conducting effective code reviews with constructive feedback
Using GitHub's collaboration features for team coordination
Contributing to open-source projects with proper etiquette
Troubleshooting common collaboration issues
Best practices for maintaining healthy team dynamics
With strong collaboration skills, you're ready to learn about using GitHub Pages for documentation and hosting static websites!