I have different old branches I want to delete but I want to see the commits/diff I originally introduced in the branch at that time.
I don't want the diff between "master" and "branch" but all the unified commits introduced in that branch as a single diff.
Is it possible?
If you need the diff or list of commits "from" a branch which is already merged into your master
, like this
A---B---F---G---H---I---J <<< master <<< HEAD
\ /
C---D---E <<< branch-a
Here, H
is the merge commit, and B
the commit branch-a
branched from.
If you do
git diff master branch-a
as you noted, you won't get the diff for the list of commits on branch-a
, but the for accumulated changes that happened since the merge commit, which is entirely different.
So you'd have to diff between the tip of branch-a
( E
) and the merge-base between the two branches ( B
) :
git diff `git merge-base branch-a master` branch-a
...which, as usefully noted by jthill below , can be a bit less verbose with the special three-dots syntax , to the same effect :
git diff master...branch-a
And of course you can add here any options you need to display code diffs or file lists, in the format you want. Maybe tell us more in case of a specific format.
But alternatively you could also want to get the list of commits, and it wouldn't be much more difficult to extract, you could do
git log `git merge-base branch-a master`..branch-a
(mind the two dots to make it a range, not to be confused with above three-dots)
Also, for any remaining doubts, check the very useful doc on revisions.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.