7th March 2021 - 5 minutes read time
The git diff command will allow you to view the differences in your workspace. This can be used in a number of ways to look at the differences in a file, in a branch or between two branches.
For example, you can view the differences in your current workspace by just running git diff on its own. By supplying a file you can look at the differences in just that file.
To compare the difference between one branch and another you use '..' to separate the branch names. For example, to look at the differences between the head of the 'main' branch and the head of a feature branch use this syntax.
git diff main..feature_branch
This can often be quite noisy, especially on large projects, so to check just one directory between two branches you can add the directory path to the command.