0

I have seen plenty of articles related to this but they all seem to focus on determining the branch point only 1 layer deep. For instance:

master: A -- B -- E
              \
feature        C -- D

They focus on finding "B"

I would like to be able to find the first a branch point in a sub-branch such as:

master: A -- B -- E -- H
              \
feature-1      C -- D -- F
                     \
feature-2              G -- I 

I this case I would like to:

  1. Be able to find D (and preferably the name of the branch "feature-1" as well) Additionally, I don't necessarily know the name of the branch it came from.
  2. Find this as part of a script so I can run it automatically. So manually looking at the tree is not a valid option.
caffein
  • 575
  • 8
  • 26
  • It looks like you're still only looking "1 layer" deep (you want to find where `feature2` branches from `feature1`, just like in your first example someone finds where `feature` branches from `master`. – larsks May 24 '22 at 17:54
  • How do you define that `feature-2` sprouts off of `feature-1`, as opposed to that `feature-1` sprouts off of `feature-2`? When you have found the answer to this question, you are closer to a solution. – j6t May 24 '22 at 18:22
  • That is an excellent point j6t. I'll look into that and see what I can find. I think the big problem I've been running into is that I don't know the name of the branch it branched off from. Every other solution I've seen assumes it is master, but that isn't necessarily true here. There may be a way to automatically figure that out though. – caffein May 24 '22 at 18:35
  • Branch names just point to one commit. There are no parent/child relationship between branches. If you control the scripts, you can add your own notion (and record relationships in `.git/config` using `git config` commands and your own name spaces) but otherwise there's no actual answer. – torek May 25 '22 at 09:24

0 Answers0