For each defect in code I create separate branch. When defect is fixed I merge this branch in master, so I have history like illustrated below (we see two branches with fixes):
defect1 fix defect2 fix
a---b---c---d e---f
/ \ / \
---o---1---x---y---z---2---o---3---w---4---o---
The question is how to get diff for fix1 (between branch start (1) and branch end (2)) or fix2 (diff between (3) and (4)) at any point of time (e.g. for any closed defect in past).
Update: actual question is how to figure out SHA summs of a
and d
or e
and f
to perform next obvious diff command diff <commit> <commit>
In order to compare two branches easily, you have to use the “git diff” command and provide the branch names separated by dots. Using this command, Git will compare the tip of both branches (also called the HEAD) and display a “diff” recap that you can use to see modifications.
Comparing branches is as easy as selecting the “compare to branch” option while perusing the feature branch you'd like to compare to another. The compare to branch option in GitHub Desktop is located under the “Branch” in the main menu at the top of the interface.
Find the merge base, and then check if git diff --name-only $merge_base branchA and git diff --name-only $merge_base branchB have anything in common. Otherwise, you'll need a work tree to try the merge in. You could easily create a second one - either clone the repository, or to save space, just create a work tree.
Note: this is equivalent, as detailed in "Not able to think of a case where git diff master..lab
and git diff master...lab
would be different", to:
git diff master...defect1-fix-branch
git diff A...B
is equivalent togit diff $(git merge-base A B) B
(From "git diff doesn't show enough")
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