Working with github/gitlab, using feature branches in many cases pull requests go out of date while waiting for a review and need to be rebased on top of the new target branch (master) after a while.
This will sometimes create conflicts that need to be solved.
After a rebase I would like to compare the old and the new branch in relation to the target branch, to verify no errors have been made while solving the conflicts. Meaning I would like to verify which lines are going to change after merging the new version of the PR.
So basically I would like to diff the result of git diff branch origin/master and git diff origin/branch origin/master - what changed in the diff output on the PR view of github/gitlab between the old and new versions.
Is there a command to do this?
Yes, you can use the form of git-diff that takes multiple commits:
git diff <commit> <commit>… <commit>
From the documentation:
This form is to view the results of a merge commit. The first listed must be the merge itself; the remaining two or more commits should be its parents.
In your case, you want to compare the merge commit between the rebased branch and origin/master with the merge commit between the old origin/branch and origin/master; the comparison then becomes:
git diff branch origin/master origin/branch
where branch is the "merge commit" and origin/master and origin/branch are its "parents".
In case of a conflict, Git is going to produce the following diff:
- line in origin/master (the first "parent" commit)
- line in origin/branch (the second "parent" commit)
+ line in branch (the merge commit)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With