Stacked diffs, also known as stacked changes or pull requests (PRs), are a series of code changes made on top of each other in a specific order. It's like stacking blocks where each block is a small, independent change that contributes to building a larger feature.
Why Use Stacked Diffs?
Small & Manageable Changes: Breaks down large features into smaller, more manageable pieces, making it easier to review and test.
Continuous Progress: Allows you to keep working on subsequent changes without waiting for the earlier ones to be merged.
Easier Reviews: Smaller diffs make it easier for reviewers to understand and give feedback.
Isolated Testing: Each change can be tested independently, reducing the risk of bugs.
How to Create Stacked Diffs?
Start Small: Make a small change in your code and submit it as a PR.
Stack On: Create a new branch from the first PR, make another change, and submit a new PR.
Rinse & Repeat: Continue stacking new changes on top of the previous ones.
Graphite and Stacked Diffs
Graphite is a tool that simplifies working with stacked diffs. It keeps track of the order and dependencies of your changes, making it easy to manage and submit stacks of PRs.
Tips for Effective Stacking
Keep each diff focused on a single change.
Ensure each diff builds off the changes made in the previous one.
Regularly sync with the main branch to avoid merge conflicts.
Review and merge from the bottom up - the oldest diffs first.
Remember, the key to successful stacked diffs is to keep each change small, focused, and reviewable.