-
Notifications
You must be signed in to change notification settings - Fork 18
Generating a diff
The generation of a diff can be done in multiple ways.
The way which works in most places (CI server and locally with non committed changed)
git diff $(git merge-base origin/master HEAD) > /tmp/diff.txt
This shows the all differences from the point the branch diverged with origin/master
This is the safest version to use for both uncommitted changed (for example a pre commit hook) and in the CI server (finding the difference for the checked in code)
git diff options also work here such as ignoring whitespace however this is not recommended due to some of the checks failing on whitespace (eg PSR-2)
git diff origin/master... > /tmp/diff.txt
The above command is similar to the first, but will only check the committed differences and not the local ones. This syntax is much nicer but will only work on a CI server or a pre push hook. A branch name can be put after the three dots if you wish to generate a diff for a branch you are not currently on.