Shaun Luttin
Shaun Luttin

Reputation: 141712

Determine a git branch's ancestor branch

I have a long running git branch. I am trying to determine its ancestor. For example, if I am on a staging branch that split from master, the following commands would be perfect:

> git log --show-ancestor-branch
master

or

> git log --show-branches-with-common-ancestors
master

What I mean by ancestor is that master in the following log would be an ancestor of staging.

* 741c3fd (master) 
| * a8503ef (HEAD, staging) 
|/
| 
|
* bd783e3 Add simple query expressions

The following did not work:

*  `git log --ancestry-path`
* ` git merge-base -a`

The following would work in subversion:

svn log --stop-on-copy

Upvotes: 0

Views: 1258

Answers (1)

Shay Nehmad
Shay Nehmad

Reputation: 1163

I don't think that's possible to do, since in the end a branch is just a pointer to some commit hash, and it doesn't "leave marks" where it's been.

You could see who has the nearest common ancestor of your branch but that is not 100% guaranteed to be what you're looking for.

One thing we did on my team was, one the first commit in a new branch, write

Branched from some_branch

And we could track it like that. It's not very l33t but hey, it works :)

Upvotes: 2

Related Questions