What command displays the difference between two branches?
Posted by RoseHrs
Last Updated: June 16, 2024
To display the difference between two branches in Git, you can use the git diff command followed by the names of the two branches you want to compare. The general syntax is:
git diff branch1 branch2
For example, if you want to see the difference between main and feature-branch, you would use:
git diff main feature-branch
This command will show you the changes that are present in feature-branch but not in main. If you want to see a summary of changes or a specific format, you can add options like --stat for a summary or --name-only for just the file names. For instance:
git diff --stat main feature-branch
This summarizes the changes in terms of file modifications.