6. GitHub Workflows: Pull Requests, Code Review, and Collaboration
GitHub is the world's most popular platform for Git-based collaboration. Pull requests are the foundation of modern software development — they enable code review, discussion, and quality control before merging. Understanding GitHub workflows is essential for professional development. Over 90% of professional developers use GitHub, and pull requests are how they collaborate.
The key insight is that pull requests are more than just merging — they're a discussion forum, a review tool, and a quality gate. They enable teams to collaborate effectively, catch bugs early, and maintain code quality. Understanding pull requests is essential for working in any team. A pull request is where code is reviewed, discussed, and approved before it becomes part of the codebase.
This module covers creating pull requests, reviewing code, managing reviews, and merging strategies. You'll learn about GitHub flow, protected branches, and the GitHub UI. This module focuses on the GitHub-specific workflow that powers modern software development.
Pull Requests: The Core of Collaboration
A pull request is a request to merge changes from one branch to another. It's created in the GitHub UI and includes a description, commit history, and discussion. Pull requests are the center of GitHub collaboration — they're where code is reviewed, discussed, and approved before merging. Pull requests enable code review, which catches bugs, improves code quality, and spreads knowledge across the team. They also provide a record of why changes were made. This is essential for maintainability.
The pull request workflow is standard in modern development. You create a branch, make changes, push to GitHub, and open a pull request. Reviewers comment, suggest changes, and approve the PR. The author responds to feedback and updates the PR. This conversation is documented in the PR, providing historical context for every change. This is why PRs are so valuable — they capture the reasoning behind changes.
Code Review Best Practices
Effective code review is essential for team success. Reviewers should look for bugs, design issues, performance problems, and maintainability concerns. They should be respectful and constructive. Authors should respond to feedback and make changes as needed. Code review is not about finding fault — it's about improving quality. It's a collaborative process that helps the whole team.
Good code review is a skill that takes practice. Be specific in your feedback — point to exact lines and explain why something should change. Be constructive — suggest improvements, not just problems. Be timely — review PRs promptly so work doesn't stall. Be thorough — check for edge cases and hidden issues. A healthy review culture makes the whole team better.
- Be respectful: Focus on the code, not the person.
- Be specific: Point to exact lines and explain why.
- Be constructive: Suggest improvements, not just problems.
- Be timely: Review PRs promptly.
- Be thorough: Check for edge cases and hidden issues.
Protected Branches and Branch Protection Rules
Protected branches prevent direct pushes and enforce quality gates. They're essential for maintaining code quality in production branches. Common protection rules: require pull request reviews, require status checks to pass, and prevent force pushes. Protected branches are configured in the GitHub repository settings. They ensure that only reviewed, tested code is merged to critical branches. This is a best practice for all production repositories.
Branch protection rules are how teams enforce quality standards. Requiring reviews ensures code is checked before merging. Requiring status checks ensures CI passes. Preventing force pushes protects history. These rules are essential for maintaining a stable main branch in any professional codebase.
Step-by-Step: Creating a Pull Request
Follow these steps to create your first pull request on GitHub. This is the standard workflow for contributing to any project.
Step 1: Fork and clone the repository
Go to a repository on GitHub and click the Fork button. Then clone your fork:git clone https://github.com/your-username/repo.gitcd repo
Step 2: Create a feature branchgit checkout -b feature/my-change
Use a descriptive branch name that indicates what you're working on.
Step 3: Make your changes
Edit files, add new files, or delete files. Then stage and commit:git add .git commit -m <strong><code>Add my feature
Step 4: Push to your forkgit push -u origin feature/my-change
The -u flag sets up tracking so future pushes can just use git push.
Step 5: Open a pull request
Go to the original repository on GitHub. Click the Pull requests tab, then New pull request. Select compare across forks, choose your fork and branch, and create the PR. Add a descriptive title and explanation of what you changed and why.
Step 6: Respond to feedback
Reviewers will comment on your PR. Make changes as requested:git add .git commit -m <strong><code>Address review feedbackgit push
The PR automatically updates with your new commits.
Try It Yourself: Find an open source project with a good first issue label, fork it, and make a small contribution. This is the best way to learn the full PR workflow.
Knowledge Check
Ready to test your understanding of 6. GitHub Workflows: Pull Requests, Code Review, and Collaboration?