How to show Git diff between branches

Comparing differences between Git branches is essential for code reviews, understanding feature changes, and planning merges in collaborative development. As the creator of CoreUI with over 25 years of development experience, I regularly compare branches to review feature implementations and assess merge impacts. The most straightforward approach is using git diff branch1 branch2 to see all differences between two branches. This command provides comprehensive insight into what changes will be introduced when merging branches.

Use git diff branch1 branch2 to show all differences between two Git branches.

git diff main feature-branch

This command displays all differences between the ‘main’ branch and ‘feature-branch’, showing what changes exist in the feature branch that aren’t in main. The output uses the standard diff format with + for added lines and - for removed lines. You can reverse the comparison by switching the branch order, or use git diff feature-branch main to see what would be removed when merging.

Best Practice Note:

This is our standard workflow in CoreUI development for reviewing feature branches before merging. Use git diff --name-only main feature-branch to see only the list of changed files without the detailed diff content.


Speed up your responsive apps and websites with fully-featured, ready-to-use open-source admin panel templates—free to use and built for efficiency.


About the Author

Subscribe to our newsletter
Get early information about new products, product updates and blog posts.

Answers by CoreUI Core Team