2

How can I best visualize overlapping changes in a range / set of git commits within a branch? Thus changes which would likely create rebase conflicts when I would reorder the commits with rebase -i.

kxr
  • 4,841
  • 1
  • 49
  • 32
  • 2
    Rebase applies commits one by one. You won't know the next "overlap" until you resolve conflict of a previously rebased commit – Alexey S. Larionov Dec 22 '22 at 11:51
  • @Alexey Of course such visualization would not know how the programmer would resolve a conflict, which could happen in a highly non-local way. Thus the question for a light-weight local overlap kind of visualization of the situation: changes in a 2nd commit which edit or are within 3 lines of changes in the 1st commit and so on. Think e.g. of `diff-tree -cc` kind of filtered visualization for merge commits w multiple parents - but suited for consecutive stuff within a branch ... – kxr Dec 22 '22 at 12:39
  • Your best bet is probably to go ahead ad do the rebase (or individual cherry-pick operations) and let the conflicts happen, then show the conflict(s). Do this on a temporary detached-HEAD and switch back to the original branch so that the cherry-pick commit(s) get abandoned. – torek Dec 22 '22 at 16:49

1 Answers1

2

If you are using Git 2.38+ (Q3 2022), you can do:

git merge-tree --write-tree --no-messages --name-only branch1 branch2

That will list files with conflicts (without actually doing the merge).
Empty output means: there is no overlap between the two branches.

That does not apply to an interactive rebase though since, as commented, potential overlap depend on the resolution of previous overlap.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Well I think this doesn't help much here. Several (consecutive) huge commits. I know there is quite overlapp / conflict on reorder. A mere list of files would not say much. I'd like to see more detailed / diff way the overlapping stuff - e.g. kind of aggregated diff. The visualization could e.g. be remotely similar to `diff-tree -cc` for multiple parents merge commits, but suited for consecutive commit stuff: 1 1st column +- from from 1st commit, 2nd from 2nd ... Or another suitable way. – kxr Dec 22 '22 at 12:30
  • @kxr You can see a diff-like result without the `--name-only` result, but I agree it does not apply well to your use case. – VonC Dec 22 '22 at 13:10
  • Nevertheless this new syntax is great to know about. Unfortunately my Git is not new enough to try it out! – matt Dec 23 '22 at 16:19