Is it possible to show whether git branches have the same commits if one of the branches has been rearranged, so they do not have the same SHA1 identifiers?

I try to get the same effect from running git branch --merged , but allow the same commits (commit message + diff) that were reinstalled at some point.

+4
source share
1 answer

Using git log with the --cherry-mark option will work. In particular, you can see a set of commits that match between branch A and branch B with the following:

 git log --cherry-mark --oneline --graph --decorate A...B 

Output Example:

 $ git log --cherry-mark --oneline --graph --decorate master...feature = 1e4f971 (HEAD, feature) Add some greetings = 926857a Add some greetings = bfede5b Add some greetings = 14099b6 (master) Add some Hellos = a0576fa Add some Hellos = 8822553 Add some Hellos 

In the above, you will see that the first 3 commits on the output for feature equivalent to the first 3 commits on the output for master , although sha identifiers and commit messages are different.

In the Linux Kernel Git white paper for git log :

 --cherry-mark 

Like --cherry-pick (see below), but mark equivalent commits with = , but not omitting them, and nonequivalent with + .

 --cherry-pick 

Omit any commit that introduces the same change as another commit on the โ€œother sideโ€ when the set of commits is limited to a symmetric difference.

For example, if you have two branches, A and B, the usual way to list all commits on only one side is with --left-right (see the example below in the description of the --left-right option). However, it shows the fixations that were selected from another branch (for example, โ€œ3rd on bโ€ can be selected from cherry from branch A). With this option, such commit pairs are excluded from the output.

You can also learn more about the syntax of the triple point trend range ... in the revision selection section of the FREE online version of Pro Git .

+3
source

Source: https://habr.com/ru/post/1497889/


All Articles