How to Compare Two Branches in Github
In this article
Comparing branches in GitHub is essential for reviewing code changes before merging and understanding the differences between different versions of your project. This feature helps developers track what has been modified, added, or removed across different branches.
This tutorial walks you through the complete process of setting up a branch comparison in GitHub, from accessing your repository to interpreting the results that show commit history and file modifications.
Here's how to compare two branches in GitHub
- Go to your GitHub repository that contains the branches you want to compare.
- Locate and click on the 'Compare & pull request' button in the repository interface.
- Use the branch dropdown menus to select your desired base and compare branches.
- Set the 'base' branch as the target branch you want to compare against.
- Choose the 'compare' branch as the source branch containing the changes you want to review.
- Review the generated comparison showing commits, file changes, and differences between your selected branches.
Your turn to show how it works.
Build a walkthrough of your product with Saltfish, then share it with your customers.
Frequently Asked Questions
The base branch is your reference point or target branch that you're comparing against, while the compare branch contains the changes you want to review. Think of the base as 'what you have' and compare as 'what you want to add or change.'



