Skip to content

Meet Graphite Agent — your collaborative AI reviewer, built right into your PR page.

Read more

Splitting code changes

Greg Foster
Greg Foster
Graphite software engineer
Try Graphite


Note

This guide explains this concept in vanilla Git. For Graphite documentation, see our CLI docs.


Table of contents

In software development, the practice of splitting commits and managing pull requests (PRs) can greatly enhance the collaborative process. By breaking down larger changes into smaller, more digestible pieces, you can facilitate easier code reviews, quicker integrations, and ultimately a more maintainable codebase. This approach is not just about keeping your project's history clean, but also about making every contribution understandable, reviewable, and manageable. Tools like Graphite can help automate and guide this process, making it easier to split changes logically and organize PRs efficiently.

Splitting commits is a nuanced art in Git. It allows developers to isolate specific changes, making it easier to track and manage updates to the code. This is particularly useful when you want to ensure that each commit represents a single logical change, enhancing the granularity and reversibility of your work. Graphite assists in this by providing interfaces to break down large changes into smaller, well-defined commits, helping developers maintain clarity and consistency in their commit history.

How Graphite helps:

  • Graphite provides intuitive interfaces to break down large changes into smaller, well-defined commits
  • The gt create command allows you to create new branches and commit changes in one streamlined operation
  • The gt modify command helps you amend the last commit with additional changes
  • Visual diff tools help you identify logical boundaries for splitting commits
  • Automated commit message suggestions help maintain consistency across your commit history

Example: Instead of committing an entire feature at once, you can use gt create -m "Add user authentication" to create a focused commit, then gt create -m "Update database schema" for the next logical unit.

In a similar vein, managing pull requests by splitting them into smaller, focused updates can dramatically improve the review process. Smaller PRs are more quickly reviewed, less likely to introduce bugs, and allow for faster deployment cycles. Graphite supports this by helping you group related commits into focused PRs, providing visibility into what each PR contains, and making it easier for reviewers to understand the context of changes.

Adopting the best practices for splitting both commits and PRs is a strategy that pays dividends in the long run. It can lead to a more effective team collaboration, a cleaner commit history, and a more systematic approach to integrating new code.

Key principles:

  • Single responsibility: Each commit and PR should address one specific concern
  • Logical grouping: Related changes should be grouped together, unrelated changes should be separated
  • Clear communication: Commit messages and PR descriptions should clearly explain the purpose and scope
  • Incremental progress: Changes should build upon each other in a logical sequence

How Graphite supports these practices:

  • Built-in guidance for creating focused commits and PRs
  • Integration with Graphite Agent AI for automated code review and suggestions
  • Visual tools for understanding commit and PR relationships
  • Automated workflows that reduce manual overhead

By implementing these practices into your workflow and leveraging Graphite to support them, you'll be taking significant steps towards a more streamlined, efficient, and collaborative development process. The combination of thoughtful commit splitting and strategic PR management creates a foundation for high-quality code delivery and team productivity.

Ready to improve your development workflow? Get started with Graphite today.

Commit splitting is the practice of breaking down large changes into smaller, more focused commits. Each commit should represent a single logical change, making it easier to understand, review, and potentially revert specific modifications.

Splitting pull requests into smaller, focused updates improves the review process by reducing cognitive load on reviewers, making it easier to identify issues, and enabling faster iteration cycles. Smaller PRs are also less likely to introduce bugs and conflicts.

Graphite provides tools and workflows specifically designed for managing complex changes. It offers stacked diffs for breaking features into dependent PRs, visual tools for understanding relationships between changes, and automation to reduce manual overhead in the splitting process.

Stacked diffs are a workflow pattern where large changes are broken down into smaller, dependent pull requests. Each diff builds on the previous one, making code reviews more manageable and reducing the complexity of large feature implementations.

Yes, Graphite is designed to work seamlessly with existing Git repositories and GitHub workflows. It enhances your current workflow rather than replacing it, providing additional tools and automation for managing commits and PRs more effectively.

Good indicators for splitting include: when a single change addresses multiple unrelated concerns, when the diff is too large to review effectively, when different parts of the change have different review requirements, or when you want to enable incremental deployment of features.

Git inspired
Graphite's CLI and VS Code extension make working with Git effortless.
Learn more

Built for the world's fastest engineering teams, now available for everyone